Class: Alf::Engine::ToArray
- Inherits:
-
Object
- Object
- Alf::Engine::ToArray
- Includes:
- Cog
- Defined in:
- lib/alf-engine/alf/engine/to_array.rb
Overview
Ensures an order of tuples, recursing on relation value attributes, that are converted as arrays as well.
Example:
res = [
{:price => 12.0, :rva => Relation(...)},
{:price => 10.0, :rva => Relation(...)}
]
ToArray.new(res, [:price, :asc]).to_a
# => [
# {:price => 10.0, :rva => [...] },
# {:price => 12.0, :rva => [...] }
# ]
Instance Attribute Summary collapse
-
#operand ⇒ Enumerable
readonly
The operand.
-
#ordering ⇒ Ordering
readonly
The ordering info.
Instance Method Summary collapse
- #_each(&block) ⇒ Object
-
#initialize(operand, ordering) ⇒ ToArray
constructor
Creates an ToArray instance.
Methods included from Cog
Constructor Details
#initialize(operand, ordering) ⇒ ToArray
Creates an ToArray instance
29 30 31 32 |
# File 'lib/alf-engine/alf/engine/to_array.rb', line 29 def initialize(operand, ordering) @operand = operand @ordering = ordering end |
Instance Attribute Details
#operand ⇒ Enumerable (readonly)
Returns The operand.
23 24 25 |
# File 'lib/alf-engine/alf/engine/to_array.rb', line 23 def operand @operand end |
#ordering ⇒ Ordering (readonly)
Returns The ordering info.
26 27 28 |
# File 'lib/alf-engine/alf/engine/to_array.rb', line 26 def ordering @ordering end |