Class: Trestle::Navigation::Block::Evaluator
- Inherits:
-
Object
- Object
- Trestle::Navigation::Block::Evaluator
show all
- Includes:
- EvaluationContext
- Defined in:
- lib/trestle/navigation/block.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(admin = nil, context = nil) ⇒ 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
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Trestle::EvaluationContext
Instance Attribute Details
#items ⇒ Object
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, options={})
@current_group = Group.new(name, options)
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, options={})
if path.is_a?(Hash)
options = path
path = nil
end
if options[:group]
group = Group.new(options[:group])
elsif @current_group
group = @current_group
end
options = options.merge(group: group) if group
options = options.merge(admin: @admin) if @admin
items << Item.new(name, path || default_path, options)
end
|