class Shoppe::NavigationManager
Attributes
identifier[R]
Public Class Methods
build(identifier, &block)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 12 def self.build(identifier, &block) manager = self.new(identifier.to_s) manager.instance_eval(&block) if block_given? managers << manager end
create(identifier)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 8 def self.create(identifier) managers << self.new(identifier.to_s) end
find(identifier)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 18 def self.find(identifier) managers.select { |m| m.identifier == identifier.to_s }.first end
managers()
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 4 def self.managers @managers ||= [] end
new(identifier)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 28 def initialize(identifier) @identifier = identifier end
render(identifier)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 22 def self.render(identifier) find(identifier).try(:to_html) end
Public Instance Methods
add_item(identifier, options = {}, &block)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 36 def add_item(identifier, options = {}, &block) item = NavigationItem.new item.manager = self item.identifier = identifier.to_s item.url = options[:url] if options[:url] item.link_options = options[:link_options] if options[:link_options] item.active_if = block if block_given? items << item end
items()
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 32 def items @items ||= [] end
remove_item(identifier)
click to toggle source
# File lib/shoppe/navigation_manager.rb, line 46 def remove_item(identifier) items.delete_if { |i| i.identifier.to_s == identifier.to_s } end