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

#initializeScopes

Returns a new instance of Scopes.



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

def initialize
  @blocks = []
end

Instance Attribute Details

#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



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

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

#evaluate(context) ⇒ Object

Evaluates each of the scope blocks within the given admin context and returns a hash of Scope objects keyed by the scope name.



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

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