Class: Alf::Engine::Rename

Inherits:
Object
  • Object
show all
Includes:
Cog
Defined in:
lib/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"}
#    ]

Constant Summary

Constants included from Cog

Cog::EMPTY_CHILDREN, Cog::EMPTY_OPTIONS

Instance Attribute Summary collapse

Attributes included from Compiler::Cog

#compiler, #expr

Instance Method Summary collapse

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, renaming, expr = nil, compiler = nil) ⇒ Rename

Creates a Rename instance


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

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

Instance Attribute Details

#operandEnumerable (readonly)


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

def operand
  @operand
end

#renamingRenaming (readonly)


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

def renaming
  @renaming
end

Instance Method Details

#_eachObject


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

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

#argumentsObject


39
40
41
# File 'lib/alf/engine/rename.rb', line 39

def arguments
  [ renaming ]
end