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(**defaults, &block) ⇒ Object
- #apply_options!(options) ⇒ 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(**defaults, &block) ⇒ Object
11 12 13 |
# File 'lib/trestle/scopes/definition.rb', line 11 def append(**defaults, &block) @blocks << Block.new(**defaults, &block) end |
#apply_options!(options) ⇒ Object
15 16 17 |
# File 'lib/trestle/scopes/definition.rb', line 15 def () @options.merge!() 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.
21 22 23 |
# File 'lib/trestle/scopes/definition.rb', line 21 def evaluate(context) @blocks.map { |block| block.scopes(context) }.flatten.index_by(&:name) end |