Sha256: 4bb90087c9cfdaf560a50741cd41b86fbb9a6149037f8a707434cd086b5aab17

Contents?: true

Size: 640 Bytes

Versions: 2

Compression:

Stored size: 640 Bytes

Contents

module MenuBuilder
  module ViewHelpers
    class Menu
      def initialize(context)
        @context = context
        @menu_items = @context.instance_variable_get('@menu_items')
      end

      def included_in_current_items?(item)
        @menu_items.present? && @menu_items.include?(item.to_sym)
      end

      def method_missing(item, *args, &block)
        css_class = "current" if included_in_current_items? item
        @context.content_tag :li, @context.link_to(*args, &block), :class=>css_class
      end
    end

    def menu(options={}, &block)
      content_tag :ul, capture(Menu.new(self), &block), options
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
menu_builder-0.4.1 lib/menu_builder/helper.rb
menu_builder-0.4.0 lib/menu_builder/helper.rb