Sha256: cdd9067c16d6c457a7dae21994a1b73bed840c6fa92a010d0e043f193d2a0c85

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 Bytes

Contents

# Assists in the creation of navigation menus
module Manageable
  module Helpers
    class NavigationBuilder
      attr_reader :item_list
      include Enumerable

      def initialize
        @item_list = []
      end

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

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
manageable-0.1.4 lib/manageable/helpers/navigation_builder.rb
manageable-0.1.3 lib/manageable/helpers/navigation_builder.rb
manageable-0.1.2 lib/manageable/helpers/navigation_builder.rb
manageable-0.1.1 lib/manageable/helpers/navigation_builder.rb