Class: Refinery::Menu

Inherits:
Object
  • Object
show all
Defined in:
core/lib/refinery/menu.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects = nil) ⇒ Menu



4
5
6
# File 'core/lib/refinery/menu.rb', line 4

def initialize(objects = nil)
   append(objects)
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items



15
16
17
# File 'core/lib/refinery/menu.rb', line 15

def items
  @items
end

Instance Method Details

#append(objects) ⇒ Object



8
9
10
11
12
13
# File 'core/lib/refinery/menu.rb', line 8

def append(objects)
  Array(objects).each do |item|
    item = item.to_refinery_menu_item if item.respond_to?(:to_refinery_menu_item)
    items << MenuItem.new(self, item)
  end
end

#rootsObject



21
22
23
# File 'core/lib/refinery/menu.rb', line 21

def roots
  @roots ||= select { |item| item.orphan? && item.depth == minimum_depth }
end

#to_sObject



25
26
27
# File 'core/lib/refinery/menu.rb', line 25

def to_s
  map(&:title).join(' ')
end