Class: TMBundle::Menu::Item
- Inherits:
-
Object
- Object
- TMBundle::Menu::Item
- Defined in:
- lib/tm_bundle/item.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#items ⇒ Object
Returns the value of attribute items.
-
#name ⇒ Object
Returns the value of attribute name.
-
#order ⇒ Object
Returns the value of attribute order.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Instance Method Summary collapse
- #checkout(options = {}) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(uuid, order, name: nil, items: [], parent: nil) ⇒ Item
constructor
A new instance of Item.
- #inspect ⇒ Object
- #name? ⇒ Boolean
- #process_items(uuids) ⇒ Object
- #root? ⇒ Boolean
- #separator? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(uuid, order, name: nil, items: [], parent: nil) ⇒ Item
Returns a new instance of Item.
5 6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#exclude ⇒ Object
Returns the value of attribute exclude.
4 5 6 |
# File 'lib/tm_bundle/item.rb', line 4 def exclude @exclude end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/tm_bundle/item.rb', line 4 def items @items end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/tm_bundle/item.rb', line 4 def name @name end |
#order ⇒ Object
Returns the value of attribute order.
4 5 6 |
# File 'lib/tm_bundle/item.rb', line 4 def order @order end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/tm_bundle/item.rb', line 4 def parent @parent end |
#uuid ⇒ Object
Returns the value of attribute uuid.
4 5 6 |
# File 'lib/tm_bundle/item.rb', line 4 def uuid @uuid end |
Instance Method Details
#checkout(options = {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/tm_bundle/item.rb', line 14 def checkout( = {}) self.name ||= [:name] self.parent ||= [:parent] self.order ||= [:order] self.items = Array.wrap([:items]) self end |
#eql?(other) ⇒ Boolean
30 31 32 |
# File 'lib/tm_bundle/item.rb', line 30 def eql?(other) uuid == other.uuid end |
#inspect ⇒ Object
34 35 36 |
# File 'lib/tm_bundle/item.rb', line 34 def inspect "#{order||:nil}> * #{name || uuid}" end |
#name? ⇒ Boolean
38 39 40 |
# File 'lib/tm_bundle/item.rb', line 38 def name? name.present? end |
#process_items(uuids) ⇒ Object
26 27 28 |
# 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? ⇒ Boolean
44 |
# File 'lib/tm_bundle/item.rb', line 44 def root?; !@parent; end |
#separator? ⇒ Boolean
45 |
# File 'lib/tm_bundle/item.rb', line 45 def separator?; false; end |
#to_s ⇒ Object
43 |
# File 'lib/tm_bundle/item.rb', line 43 def to_s; name; end |