Class: Nav::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- Nav::Component
- Defined in:
- app/components/lookbook/nav/component.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize(tree:, id: nil, **attrs) ⇒ Component
constructor
A new instance of Component.
- #items ⇒ Object
Constructor Details
#initialize(tree:, id: nil, **attrs) ⇒ Component
Returns a new instance of Component.
8 9 10 11 12 |
# File 'app/components/lookbook/nav/component.rb', line 8 def initialize(tree:, id: nil, **attrs) @id = id @tree = tree super(**attrs, id: id) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'app/components/lookbook/nav/component.rb', line 6 def id @id end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
6 7 8 |
# File 'app/components/lookbook/nav/component.rb', line 6 def tree @tree end |
Instance Method Details
#items ⇒ Object
14 15 16 17 18 19 |
# File 'app/components/lookbook/nav/component.rb', line 14 def items @items ||= tree.map do |node| item_class = (node.type == :directory) ? Nav::Directory::Component : Nav::Entity::Component lookbook_render item_class.new node, nav_id: id end end |