Class: BlockKit::Surfaces::Modal

Inherits:
Base
  • Object
show all
Defined in:
lib/block_kit/surfaces/modal.rb

Constant Summary collapse

MAX_TITLE_LENGTH =
24
MAX_BUTTON_LENGTH =
24
SUPPORTED_ELEMENTS =
[
  Elements::Button,
  Elements::ChannelsSelect,
  Elements::Checkboxes,
  Elements::ConversationsSelect,
  Elements::DatePicker,
  Elements::DatetimePicker,
  Elements::EmailTextInput,
  Elements::ExternalSelect,
  Elements::FileInput,
  Elements::Image,
  Elements::MultiChannelsSelect,
  Elements::MultiConversationsSelect,
  Elements::MultiExternalSelect,
  Elements::MultiStaticSelect,
  Elements::MultiUsersSelect,
  Elements::NumberInput,
  Elements::Overflow,
  Elements::PlainTextInput,
  Elements::RadioButtons,
  Elements::RichTextInput,
  Elements::StaticSelect,
  Elements::TimePicker,
  Elements::URLTextInput,
  Elements::UsersSelect
].freeze

Constants inherited from Base

Base::MAX_BLOCKS, Base::SUPPORTED_BLOCKS

Instance Method Summary collapse

Methods inherited from Base

#append, #image, inherited

Methods inherited from Base

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

Constructor Details

#initialize(attributes = {}) ⇒ Modal

Returns a new instance of Modal.



57
58
59
60
61
62
# File 'lib/block_kit/surfaces/modal.rb', line 57

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

  super
end

Instance Method Details

#as_jsonObject



64
65
66
67
68
69
70
71
72
73
# File 'lib/block_kit/surfaces/modal.rb', line 64

def as_json(*)
  super.merge(
    title: title&.as_json,
    close: close&.as_json,
    submit: submit&.as_json,
    clear_on_close: clear_on_close,
    notify_on_close: notify_on_close,
    submit_disabled: submit_disabled
  ).compact
end