class TMBundle::Menu::Item
Attributes
exclude[RW]
items[RW]
name[RW]
order[RW]
parent[RW]
uuid[RW]
Public Class Methods
new(uuid, order, name: nil, items: [], parent: nil)
click to toggle source
# File lib/tm_bundle/item.rb, line 5 def initialize(uuid, order, name: nil, items: [], parent: nil) @exclude = false self.uuid = uuid self.name = name self.items = items self.parent = parent self.order = order end
Public Instance Methods
checkout(options = {})
click to toggle source
# File lib/tm_bundle/item.rb, line 14 def checkout(options = {}) self.name ||= options[:name] self.parent ||= options[:parent] self.order ||= options[:order] self.items = Array.wrap(options[:items]) self end
eql?(other)
click to toggle source
# File lib/tm_bundle/item.rb, line 30 def eql?(other) uuid == other.uuid end
inspect()
click to toggle source
# File lib/tm_bundle/item.rb, line 34 def inspect "#{order||:nil}> * #{name || uuid}" end
items=(uuids)
click to toggle source
# File lib/tm_bundle/item.rb, line 22 def items=(uuids) @items = process_items(uuids) end
name?()
click to toggle source
# File lib/tm_bundle/item.rb, line 38 def name? name.present? end
process_items(uuids)
click to toggle source
# File lib/tm_bundle/item.rb, line 26 def process_items(uuids) uuids.map.with_index{|id, index| Menu.find_or_create_new_item(id, index, parent: uuid) } end
root?()
click to toggle source
# File lib/tm_bundle/item.rb, line 44 def root?; !@parent; end
separator?()
click to toggle source
# File lib/tm_bundle/item.rb, line 45 def separator?; false; end
to_s()
click to toggle source
# File lib/tm_bundle/item.rb, line 43 def to_s; name; end