Class: Gitlab::Database::Aggregation::PartDefinition
- Inherits:
-
Object
- Object
- Gitlab::Database::Aggregation::PartDefinition
- Defined in:
- lib/gitlab/database/aggregation/part_definition.rb
Direct Known Subclasses
ActiveRecord::Column, ActiveRecord::PartDefinition, ClickHouse::Column, ClickHouse::PartDefinition
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#secondary_expression ⇒ Object
readonly
Returns the value of attribute secondary_expression.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #format_value(val) ⇒ Object
-
#identifier ⇒ Object
part identifier.
-
#initialize(name, type, expression = nil, secondary_expression: nil, description: nil, formatter: nil) ⇒ PartDefinition
constructor
A new instance of PartDefinition.
-
#instance_key(_configuration) ⇒ Object
Returns unique key for each part configuration in given request.
- #validate_part(_plan_part) ⇒ Object
Constructor Details
#initialize(name, type, expression = nil, secondary_expression: nil, description: nil, formatter: nil) ⇒ PartDefinition
Returns a new instance of PartDefinition.
15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 15 def initialize(name, type, expression = nil, secondary_expression: nil, description: nil, formatter: nil, **) @name = name @type = type @expression = expression @secondary_expression = secondary_expression @description = description @formatter = formatter end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 7 def description @description end |
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
7 8 9 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 7 def expression @expression end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
7 8 9 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 7 def formatter @formatter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 7 def name @name end |
#secondary_expression ⇒ Object (readonly)
Returns the value of attribute secondary_expression.
7 8 9 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 7 def secondary_expression @secondary_expression end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 7 def type @type end |
Instance Method Details
#format_value(val) ⇒ Object
24 25 26 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 24 def format_value(val) formatter ? formatter.call(val) : val end |
#identifier ⇒ Object
part identifier. Must be unique across all part definitions.
33 34 35 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 33 def identifier name end |
#instance_key(_configuration) ⇒ Object
Returns unique key for each part configuration in given request. For definitions without configration the key is static For definitions with configuration the key depends on the configuration parameters Must be unique across all QueryPlan parts.
42 43 44 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 42 def instance_key(_configuration) identifier.to_s end |
#validate_part(_plan_part) ⇒ Object
28 29 30 |
# File 'lib/gitlab/database/aggregation/part_definition.rb', line 28 def validate_part(_plan_part) # no-op by default end |