Class: Trestle::Scopes
- Inherits:
-
Object
- Object
- Trestle::Scopes
- Defined in:
- lib/trestle/scopes.rb,
lib/trestle/scopes/block.rb,
lib/trestle/scopes/scope.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#admin ⇒ Object
readonly
Returns the value of attribute admin.
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
Instance Method Summary collapse
- #append(&block) ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(admin) ⇒ Scopes
constructor
A new instance of Scopes.
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
#admin ⇒ Object (readonly)
Returns the value of attribute admin.
6 7 8 |
# File 'lib/trestle/scopes.rb', line 6 def admin @admin end |
#blocks ⇒ Object (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 |