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(admin, context = nil) ⇒ Evaluator

Returns a new instance of Evaluator.


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

def initialize(admin, context=nil)
  @admin, @context = admin, context
  @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


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

def scopes
  @scopes
end

Instance Method Details

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


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

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

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