Class: Compass::Menu::Item
- Inherits:
-
Object
- Object
- Compass::Menu::Item
- Includes:
- LazyAttribute
- Defined in:
- lib/compass/menu/item.rb
Overview
It is an item builder class. It leverages Compass::LazyAttribute to be able to build its attributes based on a menu context, allowing shared methods to live in the Menu class.
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#menu ⇒ Object
readonly
Returns the value of attribute menu.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(menu, &block) ⇒ Item
constructor
A new instance of Item.
-
#item(&block) ⇒ Object
Nest items under the current item.
Constructor Details
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/compass/menu/item.rb', line 7 def items @items end |
#menu ⇒ Object (readonly)
Returns the value of attribute menu.
7 8 9 |
# File 'lib/compass/menu/item.rb', line 7 def @menu end |
Instance Method Details
#as_json(options = {}) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/compass/menu/item.rb', line 79 def as_json( = {}) { label: label, icon: icon, url: url, items: items, badge: badge_count.nonzero?, meta: , gravity: gravity }.as_json().compact_blank end |
#each(&block) ⇒ Object
73 74 75 76 77 |
# File 'lib/compass/menu/item.rb', line 73 def each(&block) return yield self unless shallow items.each(&block) end |