Class: Menuizer::Menu::Item
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Menuizer::Menu::Item
- Defined in:
- lib/menuizer/menu/item.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ Item
constructor
A new instance of Item.
- #path ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(opts) ⇒ Item
Returns a new instance of Item.
2 3 4 5 |
# File 'lib/menuizer/menu/item.rb', line 2 def initialize(opts) super @opts = opts end |
Instance Method Details
#path ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/menuizer/menu/item.rb', line 14 def path if path = @opts[:path] if path.respond_to?(:unshift) if namespace path = [namespace[0..-2].to_sym,*path] end end path else if model && model.model_name.respond_to?(:plural) :"#{namespace}#{model.model_name.plural}" end end end |
#title ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/menuizer/menu/item.rb', line 7 def title if model && model.model_name.respond_to?(:human) model.model_name.human else @opts[:title] end end |