Class: BlockKit::Layout::Actions

Inherits:
Base
  • Object
show all
Defined in:
lib/block_kit/layout/actions.rb

Constant Summary collapse

MAX_ELEMENTS =
25
SUPPORTED_ELEMENTS =
[
  Elements::Button,
  Elements::ChannelsSelect,
  Elements::Checkboxes,
  Elements::ConversationsSelect,
  Elements::DatePicker,
  Elements::DatetimePicker,
  Elements::ExternalSelect,
  Elements::MultiChannelsSelect,
  Elements::MultiConversationsSelect,
  Elements::MultiExternalSelect,
  Elements::MultiStaticSelect,
  Elements::MultiUsersSelect,
  Elements::Overflow,
  Elements::RadioButtons,
  Elements::RichTextInput,
  Elements::StaticSelect,
  Elements::TimePicker,
  Elements::UsersSelect,
  Elements::WorkflowButton
]

Constants inherited from Base

Base::MAX_BLOCK_ID_LENGTH

Instance Method Summary collapse

Methods inherited from Base

inherited

Methods inherited from Base

#==, fix, #fix_validation_errors, #fix_validation_errors!, fixes, inherited, inspect, #inspect, #pretty_print, #to_json

Constructor Details

#initialize(attributes = {}) ⇒ Actions



31
32
33
34
35
36
# File 'lib/block_kit/layout/actions.rb', line 31

def initialize(attributes = {})
  attributes = attributes.with_indifferent_access
  attributes[:elements] ||= []

  super
end

Instance Method Details

#append(element) ⇒ Object



73
74
75
76
77
# File 'lib/block_kit/layout/actions.rb', line 73

def append(element)
  elements << element

  self
end

#as_jsonObject



79
80
81
# File 'lib/block_kit/layout/actions.rb', line 79

def as_json(*)
  super.merge(elements: elements&.map(&:as_json)).compact
end