Class: Alf::Engine::Ungroup

Inherits:
Object
  • Object
show all
Includes:
Cog
Defined in:
lib/alf-engine/alf/engine/ungroup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cog

#each, #to_dot, #to_relation

Constructor Details

#initialize(operand, attribute) ⇒ Ungroup

Creates a Ungroup instance



13
14
15
16
# File 'lib/alf-engine/alf/engine/ungroup.rb', line 13

def initialize(operand, attribute)
  @operand = operand
  @attribute = attribute
end

Instance Attribute Details

#attributeAttrName (readonly)

Returns Relation-valued attribute to ungroup.

Returns:

  • (AttrName)

    Relation-valued attribute to ungroup



10
11
12
# File 'lib/alf-engine/alf/engine/ungroup.rb', line 10

def attribute
  @attribute
end

#operandEnumerable (readonly)

Returns The operand.

Returns:

  • (Enumerable)

    The operand



7
8
9
# File 'lib/alf-engine/alf/engine/ungroup.rb', line 7

def operand
  @operand
end

Instance Method Details

#_eachObject



19
20
21
22
23
24
25
26
27
# File 'lib/alf-engine/alf/engine/ungroup.rb', line 19

def _each
  operand.each do |tuple|
    tuple = tuple.dup
    tuple = tuple.to_hash unless tuple.is_a?(Hash)
    tuple.delete(@attribute).each do |subtuple|
      yield tuple.merge(subtuple)
    end
  end
end