class Tienda::NavigationManager

Attributes

identifier[R]

Public Class Methods

build(identifier, &block) click to toggle source
# File lib/tienda/navigation_manager.rb, line 11
def self.build(identifier, &block)
  manager = new(identifier.to_s)
  manager.instance_eval(&block) if block_given?
  managers << manager
end
create(identifier) click to toggle source
# File lib/tienda/navigation_manager.rb, line 7
def self.create(identifier)
  managers << new(identifier.to_s)
end
find(identifier) click to toggle source
# File lib/tienda/navigation_manager.rb, line 17
def self.find(identifier)
  managers.select { |m| m.identifier == identifier.to_s }.first
end
managers() click to toggle source
# File lib/tienda/navigation_manager.rb, line 3
def self.managers
  @managers ||= []
end
new(identifier) click to toggle source
# File lib/tienda/navigation_manager.rb, line 27
def initialize(identifier)
  @identifier = identifier
end
render(identifier) click to toggle source
# File lib/tienda/navigation_manager.rb, line 21
def self.render(identifier)
  find(identifier).try(:to_html)
end

Public Instance Methods

add_item(identifier, options = {}, &block) click to toggle source
# File lib/tienda/navigation_manager.rb, line 35
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.icon             = options[:icon]           if options[:icon]
  item.active_if        = block                    if block_given?
  items << item
end
items() click to toggle source
# File lib/tienda/navigation_manager.rb, line 31
def items
  @items ||= []
end
remove_item(identifier) click to toggle source
# File lib/tienda/navigation_manager.rb, line 46
def remove_item(identifier)
  items.remote_if { |i| i.identifier.to_s == identifier.to_s }
end