class Bmg::Operator::Transform

Transform operator.

Transforms existing attributes through computations

Example:

[{ a: 1 }] transform { a: ->(t){ t[:a]*2 } } => [{ a: 4 }]

Constants

DEFAULT_OPTIONS

Attributes

options[R]
transformation[R]

Public Class Methods

new(type, operand, transformation, options = {}) click to toggle source
# File lib/bmg/operator/transform.rb, line 17
def initialize(type, operand, transformation, options = {})
  @type = type
  @operand = operand
  @transformation = transformation
  @options = DEFAULT_OPTIONS.merge(options)
end

Public Instance Methods

each() { |call| ... } click to toggle source
# File lib/bmg/operator/transform.rb, line 30
def each
  return to_enum unless block_given?
  t = transformer
  @operand.each do |tuple|
    yield t.call(tuple)
  end
end
to_ast() click to toggle source
# File lib/bmg/operator/transform.rb, line 38
def to_ast
  [ :transform, operand.to_ast, transformation.dup ]
end