Class: Alf::Engine::Ungroup
- Inherits:
-
Object
- Object
- Alf::Engine::Ungroup
- Includes:
- Cog
- Defined in:
- lib/alf/engine/ungroup.rb
Constant Summary
Constants included from Cog
Cog::EMPTY_CHILDREN, Cog::EMPTY_OPTIONS
Instance Attribute Summary collapse
-
#attribute ⇒ AttrName
readonly
Relation-valued attribute to ungroup.
-
#operand ⇒ Enumerable
readonly
The operand.
Attributes included from Compiler::Cog
Instance Method Summary collapse
- #_each ⇒ Object
- #arguments ⇒ Object
-
#initialize(operand, attribute, expr = nil, compiler = nil) ⇒ Ungroup
constructor
Creates a Ungroup instance.
Methods included from Cog
#children, #each, #options, #to_s
Methods included from Compiler::Cog
#cog_orders, #orderedby?, #relation_type, #to_ascii_tree, #to_cog, #to_relation
Constructor Details
#initialize(operand, attribute, expr = nil, compiler = nil) ⇒ Ungroup
Creates a Ungroup instance
13 14 15 16 17 |
# File 'lib/alf/engine/ungroup.rb', line 13 def initialize(operand, attribute, expr = nil, compiler = nil) super(expr, compiler) @operand = operand @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ AttrName (readonly)
Returns Relation-valued attribute to ungroup.
10 11 12 |
# File 'lib/alf/engine/ungroup.rb', line 10 def attribute @attribute end |
#operand ⇒ Enumerable (readonly)
Returns The operand.
7 8 9 |
# File 'lib/alf/engine/ungroup.rb', line 7 def operand @operand end |
Instance Method Details
#_each ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/alf/engine/ungroup.rb', line 20 def _each operand.each do |tuple| tuple = tuple.dup tuple = tuple.to_hash unless tuple.is_a?(Hash) unless rva = tuple.delete(@attribute) raise "No such RVA `#{@attribute}` on #{tuple.inspect}" end rva.each do |subtuple| subtuple = symbolize(subtuple) yield tuple.merge(subtuple) end end end |
#arguments ⇒ Object
34 35 36 |
# File 'lib/alf/engine/ungroup.rb', line 34 def arguments [ attribute ] end |