Class: ActivoateHelper::NavigationBuilder

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
app/helpers/activoate_helper.rb

Overview

Assists in the creation of navigation menus

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNavigationBuilder

Returns a new instance of NavigationBuilder.



277
278
279
# File 'app/helpers/activoate_helper.rb', line 277

def initialize
  @item_list = []
end

Instance Attribute Details

#item_listObject (readonly)

Returns the value of attribute item_list.



274
275
276
# File 'app/helpers/activoate_helper.rb', line 274

def item_list
  @item_list
end

Instance Method Details

#each(&blk) ⇒ Object



281
282
283
# File 'app/helpers/activoate_helper.rb', line 281

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

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



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'app/helpers/activoate_helper.rb', line 285

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