Class: Slack::BlockKit::Element::Checkboxes
- Inherits:
-
Object
- Object
- Slack::BlockKit::Element::Checkboxes
- Defined in:
- lib/slack/block_kit/element/checkboxes.rb
Overview
A checkbox group that allows a user to choose multiple items from a list of possible options.
Constant Summary collapse
- TYPE =
'checkboxes'
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(action_id:) {|_self| ... } ⇒ Checkboxes
constructor
A new instance of Checkboxes.
- #option(value:, text:, initial: false, description: nil) ⇒ Object
Methods included from Composition::ConfirmationDialog::Confirmable
#confirmation_dialog, included
Constructor Details
#initialize(action_id:) {|_self| ... } ⇒ Checkboxes
Returns a new instance of Checkboxes.
15 16 17 18 19 20 |
# File 'lib/slack/block_kit/element/checkboxes.rb', line 15 def initialize(action_id:) @action_id = action_id @options = [] yield(self) if block_given? end |
Instance Method Details
#as_json ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/slack/block_kit/element/checkboxes.rb', line 33 def as_json(*) { type: TYPE, action_id: @action_id, options: @options.map(&:as_json), initial_options: &.map(&:as_json), confirm: confirm&.as_json }.compact end |
#option(value:, text:, initial: false, description: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/slack/block_kit/element/checkboxes.rb', line 22 def option(value:, text:, initial: false, description: nil) @options << Composition::Option.new( value: value, text: text, description: description, initial: initial ) self end |