Class: ActiveAdmin::MenuItem
- Inherits:
-
Object
- Object
- ActiveAdmin::MenuItem
- Defined in:
- lib/active_admin/menu_item.rb
Instance Attribute Summary collapse
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#should_display ⇒ Object
readonly
Don’t display if the :if option passed says so.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#current?(item) ⇒ Boolean
Used in the UI to visually distinguish which menu item is selected.
- #id ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ MenuItem
constructor
Builds a new menu item.
- #submenu ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ MenuItem
Builds a new menu item
NOTE: for :label, :url, and :if These options are evaluated in the view context at render time. Symbols are called as methods on ‘self`, and Procs are exec’d within ‘self`. Here are some examples of what you can do:
if: :admin?
url: :new_book_path
url: :awesome_helper_you_defined
label: ->{ User.some_method }
label: ->{ I18n.t 'menus.user' }
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/active_admin/menu_item.rb', line 45 def initialize( = {}) super() # MenuNode @label = [:label] @dirty_id = [:id] || [:label] @url = [:url] || '#' @priority = [:priority] || 10 @html_options = [:html_options] || {} @should_display = [:if] || proc{true} @parent = [:parent] yield(self) if block_given? # Builder style syntax end |
Instance Attribute Details
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
4 5 6 |
# File 'lib/active_admin/menu_item.rb', line 4 def @html_options end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
62 63 64 |
# File 'lib/active_admin/menu_item.rb', line 62 def label @label end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/active_admin/menu_item.rb', line 4 def parent @parent end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
4 5 6 |
# File 'lib/active_admin/menu_item.rb', line 4 def priority @priority end |
#should_display ⇒ Object (readonly)
Don’t display if the :if option passed says so
66 67 68 |
# File 'lib/active_admin/menu_item.rb', line 66 def should_display @should_display end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
63 64 65 |
# File 'lib/active_admin/menu_item.rb', line 63 def url @url end |
Instance Method Details
#current?(item) ⇒ Boolean
Used in the UI to visually distinguish which menu item is selected.
69 70 71 |
# File 'lib/active_admin/menu_item.rb', line 69 def current?(item) self == item || .include?(item) end |
#id ⇒ Object
58 59 60 |
# File 'lib/active_admin/menu_item.rb', line 58 def id @id ||= Menu.normalize_id @dirty_id end |