Class: Alf::Engine::Rename

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

Overview

Renames tuples from the operand according to a Renaming info.

Example:

rel = [
  {:name => "Jones", :city => "London"}
]
Rename.new(rel, Renaming[:name => :last_name]).to_a
# => [
#      {:last_name => "Jones", :city => "London"}
#    ]

Instance Attribute Summary collapse

Attributes included from Cog

#expr

Instance Method Summary collapse

Methods included from Cog

#each, #heading, #keys, #to_cog, #to_dot, #to_relation

Constructor Details

#initialize(operand, renaming, expr = nil) ⇒ Rename

Creates a Rename instance



26
27
28
29
30
# File 'lib/alf-engine/alf/engine/rename.rb', line 26

def initialize(operand, renaming, expr = nil)
  super(expr)
  @operand = operand
  @renaming = renaming
end

Instance Attribute Details

#operandEnumerable (readonly)

Returns The operand.

Returns:

  • (Enumerable)

    The operand



20
21
22
# File 'lib/alf-engine/alf/engine/rename.rb', line 20

def operand
  @operand
end

#renamingRenaming (readonly)

Returns Renaming info.

Returns:

  • (Renaming)

    Renaming info



23
24
25
# File 'lib/alf-engine/alf/engine/rename.rb', line 23

def renaming
  @renaming
end

Instance Method Details

#_eachObject



33
34
35
36
37
# File 'lib/alf-engine/alf/engine/rename.rb', line 33

def _each
  operand.each do |tuple|
    yield @renaming.rename_tuple(tuple)
  end
end