module Axiom::Algebra::Extension::Methods

Public Instance Methods

extend(*args, &block) click to toggle source

Return an extended relation

@example with extensions

extension = relation.extend(extensions)

@example with a context block

extension = relation.extend do |context|
  context.add(:total, context[:unit_price] * context[:quantity])
end

@param [Array] args

optional arguments

@yield [function]

Evaluate an extension function

@yieldparam [Evaluator::Context] context

the context to evaluate the function within

@return [Extension]

@api public

# File lib/axiom/algebra/extension.rb, line 140
def extend(*args, &block)
  Extension.new(self, coerce_to_extensions(*args, &block))
end

Private Instance Methods

coerce_to_extensions(extensions = Undefined, &block) click to toggle source

Coerce the arguments and block into a extensions

@param [#to_hash] extensions

optional extensions with attribute keys and function/literal values

@yield [function]

Evaluate an extension function

@yieldparam [Evaluator::Context] context

the context to evaluate the function within

@return [Extension]

@api private

# File lib/axiom/algebra/extension.rb, line 160
def coerce_to_extensions(extensions = Undefined, &block)
  if extensions.equal?(Undefined)
    header.context(&block).functions
  else
    extensions
  end
end