Class: Satis::Menus::Item
- Inherits:
-
Object
- Object
- Satis::Menus::Item
- Defined in:
- lib/satis/menus/item.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#link_attributes ⇒ Object
readonly
Returns the value of attribute link_attributes.
-
#menu ⇒ Object
readonly
Returns the value of attribute menu.
-
#scope ⇒ Object
writeonly
Sets the attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(id, link: nil, label: nil, icon: nil, link_attributes: {}, active: nil, scope: [], level: nil, type: :item, &block) ⇒ Item
constructor
A new instance of Item.
- #label ⇒ Object
Constructor Details
#initialize(id, link: nil, label: nil, icon: nil, link_attributes: {}, active: nil, scope: [], level: nil, type: :item, &block) ⇒ Item
Returns a new instance of Item.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/satis/menus/item.rb', line 10 def initialize(id, link: nil, label: nil, icon: nil, link_attributes: {}, active: nil, scope: [], level: nil, type: :item, &block) @id = id @label = label @icon = icon @link = link @link_attributes = link_attributes @scope = scope @level = level @type = type @link_attributes = @link_attributes.merge(data: { action: 'click->satis-menu#toggle' }) if type == :toggle @menu = Menu.new(scope + ["#{id}_menu".to_sym], level: level + 1, &block) if block_given? end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def app @app end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def icon @icon end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def id @id end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def level @level end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def link @link end |
#link_attributes ⇒ Object (readonly)
Returns the value of attribute link_attributes.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def link_attributes @link_attributes end |
#menu ⇒ Object (readonly)
Returns the value of attribute menu.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def @menu end |
#scope=(value) ⇒ Object (writeonly)
Sets the attribute scope
8 9 10 |
# File 'lib/satis/menus/item.rb', line 8 def scope=(value) @scope = value end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/satis/menus/item.rb', line 6 def type @type end |
Instance Method Details
#active? ⇒ Boolean
29 30 31 |
# File 'lib/satis/menus/item.rb', line 29 def active? active end |
#label ⇒ Object
23 24 25 26 27 |
# File 'lib/satis/menus/item.rb', line 23 def label return @label if @label @label ||= I18n.t(id, scope: [:menu] + @scope) end |