Class: Alf::Support::TupleScope

Inherits:
Scope
  • Object
show all
Defined in:
lib/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


77
78
79
80
# File 'lib/alf/support/tuple_scope.rb', line 77

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