Class: Refinery::Menu
- Inherits:
-
Object
- Object
- Refinery::Menu
- Defined in:
- lib/refinery/menu.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
- #in_menu ⇒ Object
-
#initialize(objects = nil) ⇒ Menu
constructor
A new instance of Menu.
- #inspect ⇒ Object
-
#live ⇒ Object
Ensure that things still work from how the menu partials worked before.
- #roots ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(objects = nil) ⇒ Menu
Returns a new instance of Menu.
13 14 15 16 17 18 19 20 |
# File 'lib/refinery/menu.rb', line 13 def initialize(objects = nil) objects.each do |item| item = item. if item.respond_to?(:to_refinery_menu_item) items << MenuItem.new(item.merge(:menu_id => id)) end if objects ::Refinery.[self.id] = self end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
22 23 24 |
# File 'lib/refinery/menu.rb', line 22 def id @id end |
#items ⇒ Object
Returns the value of attribute items.
22 23 24 |
# File 'lib/refinery/menu.rb', line 22 def items @items end |
Instance Method Details
#in_menu ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/refinery/menu.rb', line 58 def Refinery.deprecate({ :what => "'in_menu' on a ::Refinery::Menu instance", :when => '1.1 with no replacement' }) self end |
#inspect ⇒ Object
41 42 43 |
# File 'lib/refinery/menu.rb', line 41 def inspect items.map(&:inspect) end |
#live ⇒ Object
Ensure that things still work from how the menu partials worked before.
49 50 51 52 53 54 55 56 |
# File 'lib/refinery/menu.rb', line 49 def live Refinery.deprecate({ :what => "'live' on a ::Refinery::Menu instance", :when => '1.1 with no replacement' }) self end |
#roots ⇒ Object
33 34 35 |
# File 'lib/refinery/menu.rb', line 33 def roots @roots ||= items.select {|item| item.parent_id.nil?} end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/refinery/menu.rb', line 37 def to_s items.map(&:title).join(' ') end |