Class: Trestle::Scopes::Definition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDefinition

Returns a new instance of Definition.



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

def initialize
  @blocks = []
  @options = {}
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



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

def blocks
  @blocks
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#append(&block) ⇒ Object



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

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.



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

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