Class: Slack::BlockKit::Element::MultiStaticSelectElement

Inherits:
StaticSelectElement show all
Defined in:
lib/slack/block_kit/element/multi_static_select_element.rb

Instance Attribute Summary collapse

Attributes inherited from StaticSelectElement

#initial_option, #option_groups, #options

Attributes inherited from SelectElement

#confirm, #placeholder

Attributes inherited from Slack::BlockKit::Element

#action_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StaticSelectElement

#valid?

Methods inherited from SelectElement

#valid?

Methods inherited from Slack::BlockKit::Element

[], #type, #valid?

Constructor Details

#initializeMultiStaticSelectElement

Returns a new instance of MultiStaticSelectElement.



18
19
20
21
# File 'lib/slack/block_kit/element/multi_static_select_element.rb', line 18

def initialize
  super
  @initial_options = TypeRestrictedArray.new(CompositionObjects::Option)
end

Instance Attribute Details

#initial_optionsObject (readonly)

Returns the value of attribute initial_options.



9
10
11
# File 'lib/slack/block_kit/element/multi_static_select_element.rb', line 9

def initial_options
  @initial_options
end

#max_selected_itemsObject

Returns the value of attribute max_selected_items.



9
10
11
# File 'lib/slack/block_kit/element/multi_static_select_element.rb', line 9

def max_selected_items
  @max_selected_items
end

Class Method Details

.populate(hash, object) ⇒ Object



11
12
13
14
15
16
# File 'lib/slack/block_kit/element/multi_static_select_element.rb', line 11

def self.populate(hash, object)
  hash[:initial_options].each(&object.initial_options.method(:<<)) if hash.key?(:initial_options)
  object.max_selected_items = hash[:max_selected_items] if hash.key?(:max_selected_items)

  super(hash, object)
end

Instance Method Details

#to_hObject



29
30
31
32
33
34
# File 'lib/slack/block_kit/element/multi_static_select_element.rb', line 29

def to_h
  super.merge(
    initial_options: initial_options&.to_h,
    max_selected_items: max_selected_items || 1
  ).compact
end