Class: Trestle::Scopes::Definition
- Inherits:
-
Object
- Object
- Trestle::Scopes::Definition
- Defined in:
- lib/trestle/scopes/definition.rb
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #append(options = {}, &block) ⇒ Object
-
#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.
-
#initialize ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize ⇒ Definition
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
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
4 5 6 |
# File 'lib/trestle/scopes/definition.rb', line 4 def blocks @blocks end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/trestle/scopes/definition.rb', line 4 def @options end |
Instance Method Details
#append(options = {}, &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 |