Class: Warb::Components::ListAction
- Inherits:
-
Object
- Object
- Warb::Components::ListAction
- Defined in:
- lib/warb/components/action.rb
Instance Attribute Summary collapse
-
#button_text ⇒ Object
Returns the value of attribute button_text.
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
- #add_section(**args) ⇒ Object
-
#initialize(button_text: nil, sections: []) ⇒ ListAction
constructor
A new instance of ListAction.
- #to_h ⇒ Object
Constructor Details
#initialize(button_text: nil, sections: []) ⇒ ListAction
Returns a new instance of ListAction.
54 55 56 57 |
# File 'lib/warb/components/action.rb', line 54 def initialize(button_text: nil, sections: []) @button_text = @sections = sections end |
Instance Attribute Details
#button_text ⇒ Object
Returns the value of attribute button_text.
52 53 54 |
# File 'lib/warb/components/action.rb', line 52 def @button_text end |
#sections ⇒ Object
Returns the value of attribute sections.
52 53 54 |
# File 'lib/warb/components/action.rb', line 52 def sections @sections end |
Instance Method Details
#add_section(**args) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/warb/components/action.rb', line 59 def add_section(**args, &) section = Section.new(**args) @sections << section block_given? ? section.tap(&) : section end |
#to_h ⇒ Object
67 68 69 70 71 72 |
# File 'lib/warb/components/action.rb', line 67 def to_h { button: @button_text, sections: @sections.map(&:to_h) } end |