Class: Geri::Config::MenuItem
- Inherits:
-
Object
- Object
- Geri::Config::MenuItem
- Defined in:
- lib/geri/config/menu_item.rb
Instance Attribute Summary collapse
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#is_parent ⇒ Object
readonly
Returns the value of attribute is_parent.
-
#menu_items ⇒ Object
readonly
Returns the value of attribute menu_items.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, path_or_options = nil, options = {}) ⇒ MenuItem
constructor
A new instance of MenuItem.
- #path ⇒ Object
- #register_menu_item(title, path_or_options = nil, options = {}) {|item| ... } ⇒ Object
- #to_partial_path ⇒ Object
Constructor Details
#initialize(title, path_or_options = nil, options = {}) ⇒ MenuItem
Returns a new instance of MenuItem.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/geri/config/menu_item.rb', line 6 def initialize(title, =nil, ={}) if ! || .is_a?(Hash) = if @is_parent = true else @path = end @icon = [:icon] @title = title @priority = [:priority] || 0 @menu_items = [] end |
Instance Attribute Details
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/geri/config/menu_item.rb', line 4 def icon @icon end |
#is_parent ⇒ Object (readonly)
Returns the value of attribute is_parent.
4 5 6 |
# File 'lib/geri/config/menu_item.rb', line 4 def is_parent @is_parent end |
#menu_items ⇒ Object (readonly)
Returns the value of attribute menu_items.
4 5 6 |
# File 'lib/geri/config/menu_item.rb', line 4 def @menu_items end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
4 5 6 |
# File 'lib/geri/config/menu_item.rb', line 4 def priority @priority end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/geri/config/menu_item.rb', line 4 def title @title end |
Instance Method Details
#path ⇒ Object
25 26 27 |
# File 'lib/geri/config/menu_item.rb', line 25 def path "#{Geri::Config.admin_path}#{@path}" end |
#register_menu_item(title, path_or_options = nil, options = {}) {|item| ... } ⇒ Object
19 20 21 22 23 |
# File 'lib/geri/config/menu_item.rb', line 19 def (title, =nil, ={}) self. << item = MenuItem.new(title, , ) yield item if block_given? self..sort! { |a, b| a.priority <=> b.priority } end |
#to_partial_path ⇒ Object
29 30 31 |
# File 'lib/geri/config/menu_item.rb', line 29 def to_partial_path 'shared/menu_item' end |