Class: Slack::BlockKit::Element::OverflowElement

Inherits:
Slack::BlockKit::Element show all
Defined in:
lib/slack/block_kit/element/overflow_element.rb

Instance Attribute Summary collapse

Attributes inherited from Slack::BlockKit::Element

#action_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Slack::BlockKit::Element

[], #type

Constructor Details

#initializeOverflowElement

Returns a new instance of OverflowElement.



17
18
19
# File 'lib/slack/block_kit/element/overflow_element.rb', line 17

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

Instance Attribute Details

#confirmObject

Returns the value of attribute confirm.



8
9
10
# File 'lib/slack/block_kit/element/overflow_element.rb', line 8

def confirm
  @confirm
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/slack/block_kit/element/overflow_element.rb', line 8

def options
  @options
end

Class Method Details

.populate(hash, object) ⇒ Object



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

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

  super(hash, object)
end

Instance Method Details

#to_hObject



33
34
35
36
37
38
# File 'lib/slack/block_kit/element/overflow_element.rb', line 33

def to_h
  super.merge(
    options: options.map(&:to_h),
    confirm: confirm&.to_h
  ).compact
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/slack/block_kit/element/overflow_element.rb', line 21

def valid?
  (2..5).include?(options.size)
end