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
- #default_path ⇒ Object
- #group(name, options = {}) ⇒ Object
-
#initialize(admin = nil, context = nil) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #item(name, path = nil, options = {}) ⇒ Object
Methods included from EvaluationContext
Constructor Details
#initialize(admin = nil, context = nil) ⇒ Evaluator
Returns a new instance of Evaluator.
22 23 24 25 |
# File 'lib/trestle/navigation/block.rb', line 22 def initialize(admin=nil, context=nil) @admin, @context = admin, context @items = [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
20 21 22 |
# File 'lib/trestle/navigation/block.rb', line 20 def items @items end |
Instance Method Details
#default_path ⇒ Object
27 28 29 |
# File 'lib/trestle/navigation/block.rb', line 27 def default_path @admin ? @admin.path : nil end |
#group(name, options = {}) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/trestle/navigation/block.rb', line 49 def group(name, ={}) @current_group = Group.new(name, ) yield ensure @current_group = nil end |
#item(name, path = nil, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/trestle/navigation/block.rb', line 31 def item(name, path=nil, ={}) if path.is_a?(Hash) = path path = nil end 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 || default_path, ) end |