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