Sha256: c16b7608c268702059cbfff2e35fe23039f2f8aad947a57efa42c5fc385d75f9

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

module MenuBuilder
  module Controller
    extend ActiveSupport::Concern

    def menu_items(*items)
      @menu_items = items
    end
    alias_method :menu_item, :menu_items

    def append_menu_items(*items)
      @menu_items += items
    end
    alias_method :append_menu_item, :append_menu_items

    def prepend_menu_items(*items)
      @menu_items = items + @menu_items
    end
    alias_method :prepend_menu_item, :prepend_menu_items

    module ClassMethods
      def menu_items(*items)
        options = items.extract_options!

        before_action(options) do |controller|
          controller.instance_variable_set("@menu_items", items)
        end
      end
      alias_method :menu_item, :menu_items
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
menu_builder-0.5 lib/menu_builder/controller.rb