class Trestle::Navigation::Block::Evaluator

Attributes

items[R]

Public Class Methods

new(admin=nil, context=nil) click to toggle source
# File lib/trestle/navigation/block.rb, line 22
def initialize(admin=nil, context=nil)
  @admin, @context = admin, context
  @items = []
end

Public Instance Methods

default_path() click to toggle source
# File lib/trestle/navigation/block.rb, line 27
def default_path
  @admin ? @admin.path : nil
end
group(name, options={}) { || ... } click to toggle source
# 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={}) click to toggle source
# 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