Class: BlockKit::Layout::Input

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

Constant Summary collapse

MAX_LABEL_LENGTH =
2000
MAX_HINT_LENGTH =
2000
SUPPORTED_ELEMENTS =
[
  Elements::ChannelsSelect,
  Elements::Checkboxes,
  Elements::ConversationsSelect,
  Elements::DatePicker,
  Elements::DatetimePicker,
  Elements::EmailTextInput,
  Elements::ExternalSelect,
  Elements::FileInput,
  Elements::MultiChannelsSelect,
  Elements::MultiConversationsSelect,
  Elements::MultiExternalSelect,
  Elements::MultiStaticSelect,
  Elements::MultiUsersSelect,
  Elements::NumberInput,
  Elements::PlainTextInput,
  Elements::RadioButtons,
  Elements::RichTextInput,
  Elements::StaticSelect,
  Elements::TimePicker,
  Elements::UsersSelect,
  Elements::URLTextInput
].freeze

Constants inherited from Base

Base::MAX_BLOCK_ID_LENGTH

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from BlockKit::Layout::Base

Instance Method Details

#as_jsonObject



100
101
102
103
104
105
106
107
108
# File 'lib/block_kit/layout/input.rb', line 100

def as_json(*)
  super.merge(
    label: label&.as_json,
    element: element&.as_json,
    dispatch_action: dispatch_action,
    hint: hint&.as_json,
    optional: optional
  ).compact
end

#dispatch_action?Boolean



96
97
98
# File 'lib/block_kit/layout/input.rb', line 96

def dispatch_action?
  !!dispatch_action
end

#optional?Boolean



88
89
90
# File 'lib/block_kit/layout/input.rb', line 88

def optional?
  !!optional
end

#required?Boolean



92
93
94
# File 'lib/block_kit/layout/input.rb', line 92

def required?
  !optional?
end