Class: Trestle::Navigation::Block::Evaluator
- Inherits:
-
Object
- Object
- Trestle::Navigation::Block::Evaluator
- Includes:
- EvaluationContext
- Defined in:
- lib/trestle/navigation/block.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
- #group(name, **options) ⇒ Object
-
#initialize(admin = nil, context = nil) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #item(name, path = nil, **options) ⇒ Object
Constructor Details
#initialize(admin = nil, context = nil) ⇒ Evaluator
Returns a new instance of Evaluator.
24 25 26 27 |
# File 'lib/trestle/navigation/block.rb', line 24 def initialize(admin=nil, context=nil) @admin, @context = admin, context @items = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Trestle::EvaluationContext
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
22 23 24 |
# File 'lib/trestle/navigation/block.rb', line 22 def items @items end |
Instance Method Details
#group(name, **options) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/trestle/navigation/block.rb', line 42 def group(name, **) @current_group = Group.new(name, **) yield ensure @current_group = nil end |
#item(name, path = nil, **options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trestle/navigation/block.rb', line 29 def item(name, path=nil, **) if [:group] group = Group.new([:group]) elsif @current_group group = @current_group end .merge!(group: group) if group .merge!(admin: @admin) if @admin items << Item.new(name, path, **) end |