class Trestle::Navigation::Item
Attributes
name[R]
options[R]
path[R]
Public Class Methods
new(name, path=nil, options={})
click to toggle source
# File lib/trestle/navigation/item.rb, line 6 def initialize(name, path=nil, options={}) @name, @path, @options = name, path, options end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/trestle/navigation/item.rb, line 19 def <=>(other) priority <=> other.priority end
==(other)
click to toggle source
# File lib/trestle/navigation/item.rb, line 10 def ==(other) other.is_a?(self.class) && name == other.name && path == other.path end
Also aliased as: eql?
admin()
click to toggle source
# File lib/trestle/navigation/item.rb, line 38 def admin options[:admin] end
badge()
click to toggle source
# File lib/trestle/navigation/item.rb, line 54 def badge Badge.new(options[:badge]) if badge? end
badge?()
click to toggle source
# File lib/trestle/navigation/item.rb, line 50 def badge? !!options[:badge] end
group()
click to toggle source
# File lib/trestle/navigation/item.rb, line 34 def group options[:group] || NullGroup.new end
hash()
click to toggle source
# File lib/trestle/navigation/item.rb, line 15 def hash [name, path].hash end
html_options()
click to toggle source
# File lib/trestle/navigation/item.rb, line 58 def html_options options.except(:admin, :badge, :group, :icon, :if, :label, :priority, :unless) end
icon()
click to toggle source
# File lib/trestle/navigation/item.rb, line 46 def icon options[:icon] || Trestle.config.default_navigation_icon end
label()
click to toggle source
# File lib/trestle/navigation/item.rb, line 42 def label options[:label] || I18n.t("admin.navigation.items.#{name}", default: name.to_s.titlecase) end
priority()
click to toggle source
# File lib/trestle/navigation/item.rb, line 23 def priority case options[:priority] when :first -Float::INFINITY when :last Float::INFINITY else options[:priority] || 0 end end
visible?(context)
click to toggle source
# File lib/trestle/navigation/item.rb, line 62 def visible?(context) if options[:if] context.instance_exec(&options[:if]) elsif options[:unless] !context.instance_exec(&options[:unless]) else true end end