Sha256: b0a0465011efae93c74715e1e92be5fde3abc6f58ec08a238a4b413ea22eb402

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

module ActiveAdmin
  class Resource
    module Menu

      # Set the menu options. To not add this resource to the menu, just
      # call #menu(false)
      def menu(options = {})
        options = options == false ? { :display => false } : options
        @menu_options = options
      end

      # The options to use for the menu
      def menu_options
        @menu_options ||= {}
      end

      # Returns the name to put this resource under in the menu
      def parent_menu_item_name
        menu_options[:parent]
      end

      # Returns the name to be displayed in the menu for this resource
      def menu_item_name
        menu_options[:label] || plural_resource_name
      end

      # Returns the items priority for altering the default sort order
      def menu_item_priority
        menu_options[:priority] || 10
      end

      # Returns a proc for deciding whether to display the menu item or not in the view
      def menu_item_display_if
        menu_options[:if] || proc { true }
      end

      # Should this resource be added to the menu system?
      def include_in_menu?
        menu_options[:display] != false
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
activeadmin-0.4.4 lib/active_admin/resource/menu.rb
activeadmin-0.4.3 lib/active_admin/resource/menu.rb
activeadmin-0.4.2 lib/active_admin/resource/menu.rb
activeadmin-0.4.1 lib/active_admin/resource/menu.rb
activeadmin-0.4.0 lib/active_admin/resource/menu.rb
andrewroth_activeadmin-0.3.4.4 lib/active_admin/resource/menu.rb
andrewroth_activeadmin-0.3.4.3 lib/active_admin/resource/menu.rb
andrewroth_activeadmin-0.3.4.2 lib/active_admin/resource/menu.rb
andrewroth_activeadmin-0.3.4.1 lib/active_admin/resource/menu.rb