Class: GitlabInternalEventsCli::Metric::Identifier
- Inherits:
-
Struct
- Object
- Struct
- GitlabInternalEventsCli::Metric::Identifier
- Defined in:
- lib/gitlab_internal_events_cli/metric.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#default? ⇒ Boolean
Refers to the top-level identifiers not included in additional_properties.
-
#description ⇒ Object
returns a description of the identifier with appropriate grammar to interpolate a description of events.
-
#key_path(operator) ⇒ Object
returns a slug which can be used in the metric’s key_path and filepath.
-
#plural ⇒ Object
handles generic pluralization for unknown indentifers.
-
#reference ⇒ Object
Returns the identifier string that will be included in the yml.
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value
385 386 387 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 385 def value @value end |
Instance Method Details
#default? ⇒ Boolean
Refers to the top-level identifiers not included in additional_properties
425 426 427 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 425 def default? %w[user project namespace].include?(value) end |
#description ⇒ Object
returns a description of the identifier with appropriate grammar to interpolate a description of events
388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 388 def description if value.nil? '%s occurrences' elsif value == 'user' 'users who triggered %s' elsif %w[project namespace].include?(value) "#{plural} where %s occurred" else "#{plural} from %s occurrences" end end |
#key_path(operator) ⇒ Object
returns a slug which can be used in the metric’s key_path and filepath
407 408 409 410 411 412 413 414 415 416 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 407 def key_path(operator) case operator.value when 'unique_count' "distinct_#{reference.tr('.', '_')}_from" when 'count' 'total' when 'sum' "#{reference.tr('.', '_')}_from" end end |
#plural ⇒ Object
handles generic pluralization for unknown indentifers
401 402 403 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 401 def plural default? ? "#{value}s" : "values for '#{value}'" end |
#reference ⇒ Object
Returns the identifier string that will be included in the yml
419 420 421 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 419 def reference default? ? "#{value}.id" : value end |