Class: Fx::Aggregate
- Inherits:
-
Object
- Object
- Fx::Aggregate
- Includes:
- Comparable
- Defined in:
- lib/fx-aggregate/aggregate.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(aggregate_row) ⇒ Aggregate
constructor
A new instance of Aggregate.
- #to_schema ⇒ Object
Constructor Details
#initialize(aggregate_row) ⇒ Aggregate
Returns a new instance of Aggregate.
8 9 10 11 12 |
# File 'lib/fx-aggregate/aggregate.rb', line 8 def initialize(aggregate_row) @name = aggregate_row.fetch("name") @arguments = aggregate_row.fetch("arguments", "") @definition = aggregate_row.except("name", "arguments") end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/fx-aggregate/aggregate.rb', line 5 def arguments @arguments end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/fx-aggregate/aggregate.rb', line 5 def definition @definition end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/fx-aggregate/aggregate.rb', line 5 def name @name end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/fx-aggregate/aggregate.rb', line 14 def ==(other) other.is_a?(self.class) && name == other.name && arguments == other.arguments && definition == other.definition end |
#to_schema ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/fx-aggregate/aggregate.rb', line 21 def to_schema <<-SCHEMA create_aggregate :#{name}, sql_definition: <<-\SQL CREATE AGGREGATE #{name}(#{arguments})( #{.join(",\n").indent(6).lstrip} ); SQL SCHEMA end |