class Bmg::Operator::Extend

Extend operator.

Extends operand's tuples with attributes resulting from given computations

Example:

[{ a: 1 }] extend { b: ->(t){ 2 } } => [{ a: 1, b: 2 }]

Attributes

extension[R]

Public Class Methods

new(type, operand, extension) click to toggle source
# File lib/bmg/operator/extend.rb, line 16
def initialize(type, operand, extension)
  @type = type
  @operand = operand
  @extension = extension
end

Public Instance Methods

delete() click to toggle source
# File lib/bmg/operator/extend.rb, line 49
def delete
  operand.delete
end
each() { |extend_it(tuple)| ... } click to toggle source
# File lib/bmg/operator/extend.rb, line 28
def each
  return to_enum unless block_given?
  @operand.each do |tuple|
    yield extend_it(tuple)
  end
end
insert(arg) click to toggle source
Calls superclass method
# File lib/bmg/operator/extend.rb, line 35
def insert(arg)
  case arg
  when Hash       then operand.insert(allbut_extkeys(arg))
  when Relation   then operand.insert(arg.allbut(extension.keys))
  when Enumerable then operand.insert(arg.map{|t| allbut_extkeys(t) })
  else
    super
  end
end
to_ast() click to toggle source
# File lib/bmg/operator/extend.rb, line 53
def to_ast
  [ :extend, operand.to_ast, extension.dup ]
end
update(tuple) click to toggle source
# File lib/bmg/operator/extend.rb, line 45
def update(tuple)
  operand.update(allbut_extkeys(tuple))
end