Class: Alf::Engine::Unwrap
- Inherits:
-
Object
- Object
- Alf::Engine::Unwrap
- Includes:
- Cog
- Defined in:
- lib/alf/engine/unwrap.rb
Overview
Unwraps a tuple attribute
Constant Summary
Constants included from Cog
Cog::EMPTY_CHILDREN, Cog::EMPTY_OPTIONS
Instance Attribute Summary collapse
-
#attribute ⇒ AttrName
readonly
Name of the attribute to unwrap.
-
#operand ⇒ Enumerable
readonly
The operand.
Attributes included from Compiler::Cog
Instance Method Summary collapse
- #_each ⇒ Object
- #arguments ⇒ Object
-
#initialize(operand, attribute, expr = nil, compiler = nil) ⇒ Unwrap
constructor
Creates a SetAttr 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, attribute, expr = nil, compiler = nil) ⇒ Unwrap
Creates a SetAttr instance
16 17 18 19 20 |
# File 'lib/alf/engine/unwrap.rb', line 16 def initialize(operand, attribute, expr = nil, compiler = nil) super(expr, compiler) @operand = operand @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ AttrName (readonly)
Returns Name of the attribute to unwrap.
13 14 15 |
# File 'lib/alf/engine/unwrap.rb', line 13 def attribute @attribute end |
#operand ⇒ Enumerable (readonly)
Returns The operand.
10 11 12 |
# File 'lib/alf/engine/unwrap.rb', line 10 def operand @operand end |
Instance Method Details
#_each ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/alf/engine/unwrap.rb', line 23 def _each operand.each do |tuple| tuple = tuple.dup tuple = tuple.to_hash unless tuple.is_a?(Hash) wrapped = tuple.delete(@attribute) || {} wrapped = symbolize(wrapped) tuple.merge!(wrapped) yield tuple end end |
#arguments ⇒ Object
34 35 36 |
# File 'lib/alf/engine/unwrap.rb', line 34 def arguments [ attribute ] end |