Class: Alf::Engine::Rename
- Inherits:
-
Object
- Object
- Alf::Engine::Rename
- 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
-
#operand ⇒ Enumerable
readonly
The operand.
-
#renaming ⇒ Renaming
readonly
Renaming info.
Attributes included from Compiler::Cog
Instance Method Summary collapse
- #_each ⇒ Object
- #arguments ⇒ Object
-
#initialize(operand, renaming, expr = nil, compiler = nil) ⇒ Rename
constructor
Creates a Rename 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, 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
#operand ⇒ Enumerable (readonly)
Returns The operand.
20 21 22 |
# File 'lib/alf/engine/rename.rb', line 20 def operand @operand end |
#renaming ⇒ Renaming (readonly)
Returns Renaming info.
23 24 25 |
# File 'lib/alf/engine/rename.rb', line 23 def renaming @renaming end |
Instance Method Details
#_each ⇒ Object
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 |
#arguments ⇒ Object
39 40 41 |
# File 'lib/alf/engine/rename.rb', line 39 def arguments [ renaming ] end |