Class: Manageable::Helpers::NavigationBuilder

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/manageable/helpers/navigation_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNavigationBuilder

Returns a new instance of NavigationBuilder.



8
9
10
# File 'lib/manageable/helpers/navigation_builder.rb', line 8

def initialize
  @item_list = []
end

Instance Attribute Details

#item_listObject (readonly)

Returns the value of attribute item_list.



5
6
7
# File 'lib/manageable/helpers/navigation_builder.rb', line 5

def item_list
  @item_list
end

Instance Method Details

#each(&blk) ⇒ Object



12
13
14
# File 'lib/manageable/helpers/navigation_builder.rb', line 12

def each(&blk)
  item_list.each(&blk)
end

#item(label, path, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/manageable/helpers/navigation_builder.rb', line 16

def item(label, path, options = {})
  options[:class] ||= ""
  options[:class] << " first" if item_list.empty?
  options[:class] << " active" if options[:active]

  options[:link_options] ||= {}
  options[:link_options].merge!(:method => options[:method]) if options[:method]

  item_list << {
    :label => label,
    :href => path,
    :class => options[:class].strip,
    :link_options => options[:link_options],
    :icon => options[:icon],
    :active => !!options[:active]
  }
end