Class: Trestle::Scopes::Block

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

Defined Under Namespace

Classes: Evaluator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(admin = nil, &block) ⇒ Block

Returns a new instance of Block.


6
7
8
9
# File 'lib/trestle/scopes/block.rb', line 6

def initialize(admin=nil, &block)
  @admin = admin
  @block = block
end

Instance Attribute Details

#adminObject (readonly)

Returns the value of attribute admin


4
5
6
# File 'lib/trestle/scopes/block.rb', line 4

def admin
  @admin
end

#blockObject (readonly)

Returns the value of attribute block


4
5
6
# File 'lib/trestle/scopes/block.rb', line 4

def block
  @block
end

Instance Method Details

#scopes(context) ⇒ Object


11
12
13
14
15
# File 'lib/trestle/scopes/block.rb', line 11

def scopes(context)
  context = Evaluator.new(@admin, context)
  context.instance_exec(@admin, &block)
  context.scopes
end