lib/menu_builder/helper.rb in menu_builder-0.4.2 vs lib/menu_builder/helper.rb in menu_builder-0.4.3

- old
+ new

@@ -1,9 +1,10 @@ module MenuBuilder module ViewHelpers def menu(options={}, &block) - content_tag :ul, Menu.new(self, &block).render, options + current_class = options.delete :current_class + content_tag :ul, Menu.new(self, current_class, &block).render, options end private class MenuItem @@ -21,15 +22,16 @@ item.to_sym end end class Menu - def initialize(context, &block) - @context = context - @menu_items = context.instance_variable_get('@menu_items') - @actual_items = [] - @block = block + def initialize(context, current_class="current", &block) + @context = context + @current_class = current_class || "current" + @menu_items = context.instance_variable_get('@menu_items') + @actual_items = [] + @block = block end def method_missing item, *args, &block @actual_items << MenuItem.new(item, args, block) nil @@ -44,10 +46,10 @@ @context.content_tag :li, item.link_to_in_context(@context), html_options_for(item) end def html_options_for item css_classes = [] - css_classes << "current" if included_in_current_items? item + css_classes << "#{@current_class}" if included_in_current_items? item css_classes << "first" if first? item css_classes << "last" if last? item options = {} options[:class] = css_classes.join(" ") if css_classes.any?