Class: Slack::BlockKit::Layout::Actions
- Inherits:
-
Object
- Object
- Slack::BlockKit::Layout::Actions
- Defined in:
- lib/slack/block_kit/layout/actions.rb
Overview
A block that is used to hold interactive elements.
Constant Summary collapse
- TYPE =
'actions'
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
Instance Method Summary collapse
- #append(element) ⇒ Object
- #as_json ⇒ Object
- #button(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil) {|element| ... } ⇒ Object
- #channel_select(placeholder:, action_id:, initial: nil, emoji: nil, response_url_enabled: nil) {|element| ... } ⇒ Object
- #checkboxes(action_id:) {|element| ... } ⇒ Object
- #conversation_select(placeholder:, action_id:, initial: nil, emoji: nil, default_to_current_conversation: nil, response_url_enabled: nil) {|element| ... } ⇒ Object
- #datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|element| ... } ⇒ Object
- #external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) {|element| ... } ⇒ Object
-
#initialize(block_id: nil) {|_self| ... } ⇒ Actions
constructor
A new instance of Actions.
- #overflow_menu(action_id:) {|element| ... } ⇒ Object
- #static_select(placeholder:, action_id:, emoji: nil) {|element| ... } ⇒ Object
- #timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|element| ... } ⇒ Object
- #users_select(placeholder:, action_id:, initial: nil, emoji: nil) {|element| ... } ⇒ Object
Constructor Details
#initialize(block_id: nil) {|_self| ... } ⇒ Actions
Returns a new instance of Actions.
14 15 16 17 18 19 |
# File 'lib/slack/block_kit/layout/actions.rb', line 14 def initialize(block_id: nil) @block_id = block_id @elements = [] yield(self) if block_given? end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
12 13 14 |
# File 'lib/slack/block_kit/layout/actions.rb', line 12 def elements @elements end |
Instance Method Details
#append(element) ⇒ Object
148 149 150 151 152 |
# File 'lib/slack/block_kit/layout/actions.rb', line 148 def append(element) @elements << element self end |
#as_json ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/slack/block_kit/layout/actions.rb', line 154 def as_json(*) { type: TYPE, elements: @elements.map(&:as_json), block_id: @block_id }.compact end |
#button(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil) {|element| ... } ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/slack/block_kit/layout/actions.rb', line 21 def (text:, action_id:, style: nil, emoji: nil, url: nil, value: nil) element = Element::Button.new( text: text, action_id: action_id, style: style, emoji: emoji, url: url, value: value ) yield(element) if block_given? append(element) end |
#channel_select(placeholder:, action_id:, initial: nil, emoji: nil, response_url_enabled: nil) {|element| ... } ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/slack/block_kit/layout/actions.rb', line 36 def channel_select(placeholder:, action_id:, initial: nil, emoji: nil, response_url_enabled: nil) element = Element::ChannelsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, response_url_enabled: response_url_enabled ) yield(element) if block_given? append(element) end |
#checkboxes(action_id:) {|element| ... } ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/slack/block_kit/layout/actions.rb', line 138 def checkboxes(action_id:) element = Element::Checkboxes.new( action_id: action_id ) yield(element) if block_given? append(element) end |
#conversation_select(placeholder:, action_id:, initial: nil, emoji: nil, default_to_current_conversation: nil, response_url_enabled: nil) {|element| ... } ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/slack/block_kit/layout/actions.rb', line 50 def conversation_select(placeholder:, action_id:, initial: nil, emoji: nil, default_to_current_conversation: nil, response_url_enabled: nil) element = Element::ConversationsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, default_to_current_conversation: default_to_current_conversation, response_url_enabled: response_url_enabled ) yield(element) if block_given? append(element) end |
#datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|element| ... } ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/slack/block_kit/layout/actions.rb', line 65 def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) element = Element::Datepicker.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji ) yield(element) if block_given? append(element) end |
#external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) {|element| ... } ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/slack/block_kit/layout/actions.rb', line 91 def external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) element = Element::ExternalSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, min_query_length: min_query_length, emoji: emoji ) yield(element) if block_given? append(element) end |
#overflow_menu(action_id:) {|element| ... } ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/slack/block_kit/layout/actions.rb', line 105 def (action_id:) element = Element::OverflowMenu.new(action_id: action_id) yield(element) if block_given? append(element) end |
#static_select(placeholder:, action_id:, emoji: nil) {|element| ... } ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/slack/block_kit/layout/actions.rb', line 113 def static_select(placeholder:, action_id:, emoji: nil) element = Element::StaticSelect.new( placeholder: placeholder, action_id: action_id, emoji: emoji ) yield(element) if block_given? append(element) end |
#timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|element| ... } ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/slack/block_kit/layout/actions.rb', line 78 def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) element = Element::Timepicker.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji ) yield(element) if block_given? append(element) end |
#users_select(placeholder:, action_id:, initial: nil, emoji: nil) {|element| ... } ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/slack/block_kit/layout/actions.rb', line 125 def users_select(placeholder:, action_id:, initial: nil, emoji: nil) element = Element::UsersSelect.new( placeholder: placeholder, action_id: action_id, emoji: emoji, initial: initial ) yield(element) if block_given? append(element) end |