Class: Trestle::Scopes::Block::Evaluator

Inherits:
Object
  • Object
show all
Includes:
EvaluationContext
Defined in:
lib/trestle/scopes/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EvaluationContext

ruby2_keywords

Constructor Details

#initialize(context = nil) ⇒ Evaluator

Returns a new instance of Evaluator.


23
24
25
26
# File 'lib/trestle/scopes/block.rb', line 23

def initialize(context=nil)
  @context = context
  @scopes = []
end

Instance Attribute Details

#scopesObject (readonly)

Returns the value of attribute scopes


21
22
23
# File 'lib/trestle/scopes/block.rb', line 21

def scopes
  @scopes
end

Instance Method Details

#scope(name, scope = nil, options = {}, &block) ⇒ Object


28
29
30
31
32
33
34
35
# File 'lib/trestle/scopes/block.rb', line 28

def scope(name, scope=nil, options={}, &block)
  if scope.is_a?(Hash)
    options = scope
    scope = nil
  end

  scopes << Scope.new(@context, name, options, &(scope || block))
end