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

Constructor Details

#initialize(context = nil, **defaults) ⇒ Evaluator

Returns a new instance of Evaluator.



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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Trestle::EvaluationContext

Instance Attribute Details

#scopesObject (readonly)

Returns the value of attribute scopes.



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

def scopes
  @scopes
end

Instance Method Details

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



29
30
31
# File 'lib/trestle/scopes/block.rb', line 29

def scope(name, scope=nil, **options, &block)
  scopes << Scope.new(@context, name, **@defaults.merge(options), &(scope || block))
end