Class: Slack::BlockKit::Element::Button
- Inherits:
-
Object
- Object
- Slack::BlockKit::Element::Button
- Defined in:
- lib/slack/block_kit/element/button.rb
Overview
An interactive element that inserts a button. The button can be a trigger for anything from opening a simple link to starting a complex workflow.
Constant Summary collapse
- TYPE =
'button'
Instance Attribute Summary collapse
-
#confirm ⇒ Object
Returns the value of attribute confirm.
Instance Method Summary collapse
- #as_json ⇒ Object
- #confirmation_dialog {|@confirm| ... } ⇒ Object
-
#initialize(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil) {|_self| ... } ⇒ Button
constructor
A new instance of Button.
Constructor Details
#initialize(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil) {|_self| ... } ⇒ Button
Returns a new instance of Button.
16 17 18 19 20 21 22 23 24 |
# File 'lib/slack/block_kit/element/button.rb', line 16 def initialize(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil) @text = Composition::PlainText.new(text: text, emoji: emoji) @action_id = action_id @url = url @style = style @value = value yield(self) if block_given? end |
Instance Attribute Details
#confirm ⇒ Object
Returns the value of attribute confirm.
14 15 16 |
# File 'lib/slack/block_kit/element/button.rb', line 14 def confirm @confirm end |
Instance Method Details
#as_json ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/slack/block_kit/element/button.rb', line 34 def as_json(*) { type: TYPE, text: @text.as_json, action_id: @action_id, url: @url, value: @value, style: @style, confirm: @confirm&.as_json }.compact end |
#confirmation_dialog {|@confirm| ... } ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/slack/block_kit/element/button.rb', line 26 def confirmation_dialog @confirm = Composition::ConfirmationDialog.new yield(@confirm) if block_given? @confirm end |