Sha256: 81d29ce45d32bd5827ab32ef8436aa1e21d7f2d4730b636a342c33db1adcacb7

Contents?: true

Size: 939 Bytes

Versions: 5

Compression:

Stored size: 939 Bytes

Contents

module Geri
  module Config
    class MenuItem
      attr_reader :title, :priority, :is_parent, :menu_items, :icon

      def initialize(title, path_or_options=nil, options={})
        if !path_or_options || path_or_options.is_a?(Hash)
          options = path_or_options if path_or_options
          @is_parent = true
        else
          @path = path_or_options
        end
        @icon       = options[:icon]
        @title      = title
        @priority   = options[:priority] || 0
        @menu_items = []
      end

      def register_menu_item(title, path_or_options=nil, options={})
        self.menu_items << item = MenuItem.new(title, path_or_options, options)
        yield item if block_given?
        self.menu_items.sort! { |a, b| a.priority <=> b.priority }
      end

      def path
        "#{Geri::Config.admin_path}#{@path}"
      end

      def to_partial_path
        'shared/menu_item'
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
geri-0.1.4 lib/geri/config/menu_item.rb
geri-0.1.3 lib/geri/config/menu_item.rb
geri-0.1.1 lib/geri/config/menu_item.rb
geri-0.1.0 lib/geri/config/menu_item.rb
geri-0.0.1 lib/geri/config/menu_item.rb