Class: Trestle::Scopes

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

Defined Under Namespace

Classes: Block, Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(admin) ⇒ Scopes

Returns a new instance of Scopes.



8
9
10
11
# File 'lib/trestle/scopes.rb', line 8

def initialize(admin)
  @admin = admin
  @blocks = []
end

Instance Attribute Details

#adminObject (readonly)

Returns the value of attribute admin.



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

def admin
  @admin
end

#blocksObject (readonly)

Returns the value of attribute blocks.



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

def blocks
  @blocks
end

Instance Method Details

#append(&block) ⇒ Object



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

def append(&block)
  @blocks << Block.new(admin, &block)
end

#evaluate(context) ⇒ Object



17
18
19
# File 'lib/trestle/scopes.rb', line 17

def evaluate(context)
  @blocks.map { |block| block.scopes(context) }.flatten.index_by(&:name)
end