Class: Manageable::Helpers::NavigationBuilder
- Inherits:
-
Object
- Object
- Manageable::Helpers::NavigationBuilder
- Includes:
- Enumerable
- Defined in:
- lib/manageable/helpers/navigation_builder.rb
Instance Attribute Summary collapse
-
#item_list ⇒ Object
readonly
Returns the value of attribute item_list.
Instance Method Summary collapse
- #each(&blk) ⇒ Object
-
#initialize ⇒ NavigationBuilder
constructor
A new instance of NavigationBuilder.
- #item(label, path, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ NavigationBuilder
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_list ⇒ Object (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, = {}) [:class] ||= "" [:class] << " first" if item_list.empty? [:class] << " active" if [:active] [:link_options] ||= {} [:link_options].merge!(:method => [:method]) if [:method] item_list << { :label => label, :href => path, :class => [:class].strip, :link_options => [:link_options], :icon => [:icon], :active => !![:active] } end |