Class: Alf::Support::TupleScope

Inherits:
Scope
  • Object
show all
Defined in:
lib/alf-support/alf/support/tuple_scope.rb

Overview

Specialization of Scope for working on a tuple specifically.

This class works hand-in-hand with TupleExpression as it provides a scope for their evaluation on tuples. It also provides a handle for implementing a flyweight design pattern on tuples through the ‘__set_tuple` method.

Example:

scope = TupleScope.new
expr  = TupleExpression["status > 10"]
relation.each do |tuple|
  expr.evaluate(scope.__set_tuple(tuple))
end

Defined Under Namespace

Modules: OwnMethods

Instance Method Summary collapse

Constructor Details

#initialize(tuple = nil, extensions = [], parent = nil) ⇒ TupleScope

Creates a scope instance



65
66
67
68
# File 'lib/alf-support/alf/support/tuple_scope.rb', line 65

def initialize(tuple = nil, extensions = [], parent = nil)
  super [ OwnMethods ] + extensions, parent
  __build(@tuple = tuple) if tuple
end