class Bmg::Operator::Autowrap
Autowrap
operator.
Autowrap
can be used to structure tuples ala Tutorial D' wrap, but it works with conventions instead of explicit wrapping, and supports multiple levels or wrapping.
Examples:
[{ a: 1, b_x: 2, b_y: 3 }] => [{ a: 1, b: { x: 2, y: 3 } }] [{ a: 1, b_x_y: 2, b_x_z: 3 }] => [{ a: 1, b: { x: { y: 2, z: 3 } } }]
Autowrap
supports the following options:
-
`postprocessor: :nil|:none|:delete|Hash|Proc` see
NoLeftJoinNoise
-
`split: String` the seperator to use to split keys, defaults to `_`
Constants
- DEFAULT_OPTIONS
Attributes
options[R]
Public Class Methods
new(type, operand, options = {})
click to toggle source
# File lib/bmg/operator/autowrap.rb, line 28 def initialize(type, operand, options = {}) @type = type @operand = operand @original_options = options @options = normalize_options(options) end
Public Instance Methods
each() { |autowrap_tuple(tuple)| ... }
click to toggle source
# File lib/bmg/operator/autowrap.rb, line 45 def each return to_enum unless block_given? @operand.each do |tuple| yield autowrap_tuple(tuple) end end
same_options?(opts)
click to toggle source
# File lib/bmg/operator/autowrap.rb, line 41 def same_options?(opts) normalize_options(opts) == options end
to_ast()
click to toggle source
# File lib/bmg/operator/autowrap.rb, line 52 def to_ast [ :autowrap, operand.to_ast, @original_options.dup ] end