Sha256: 1ae80edad4268a1f15fc78c6c94927ecf0e5a07df418013a3f02ac61b3cf3098

Contents?: true

Size: 916 Bytes

Versions: 48

Compression:

Stored size: 916 Bytes

Contents

require 'push_type/menu_builder/dsl/menu_item'

module PushType
  module MenuBuilder

    class MenuItem
      attr_reader :key
      attr_accessor :text, :link, :active, :element, :item_options, :link_options, :active_class

      def initialize(key)
        @key          = key.to_sym
        @text         = key.to_s.humanize
        @active       = false
        @element      = :li
        @item_options = {}
        @link_options = {}
      end

      def build(&block)
        PushType::MenuBuilder::Dsl::MenuItem.build(self, &block)
      end

      def submenu(&block)
        @submenu ||= PushType::MenuBuilder::Menu.new
        @submenu.build(&block) if block_given?
        @submenu
      end

      def validate!
        [:text, :link].each do |field|
          raise "Missing '#{ field }' in MenuItem '#{ @key }'" unless send(field).present?
        end
        true
      end
      
    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
push_type_core-0.12.1 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.12.0 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.12.0.beta.1 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.11.2 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.11.1 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.11.0.beta.2 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.11.0.beta.1 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.4 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.3 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.2 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.1 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.0 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.0.beta.5 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.10.0.beta.3 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.9.5 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.9.3 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.9.2 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.9.1 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.9.0 lib/push_type/menu_builder/menu_item.rb
push_type_core-0.9.0.beta.4 lib/push_type/menu_builder/menu_item.rb