Class: Slack::BlockKit::Block::ActionsBlock

Inherits:
Slack::BlockKit::Block show all
Defined in:
lib/slack/block_kit/block/actions_block.rb

Instance Attribute Summary collapse

Attributes inherited from Slack::BlockKit::Block

#block_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Slack::BlockKit::Block

[], #type

Constructor Details

#initializeActionsBlock

Returns a new instance of ActionsBlock.



14
15
16
17
18
19
20
21
# File 'lib/slack/block_kit/block/actions_block.rb', line 14

def initialize
  @elements = TypeRestrictedArray.new(
    Element::ButtonElement,
    Element::SelectElement,
    Element::OverflowElement,
    Element::DatePickerElement
  )
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



8
9
10
# File 'lib/slack/block_kit/block/actions_block.rb', line 8

def elements
  @elements
end

Class Method Details

.populate(hash, object) ⇒ Object



10
11
12
# File 'lib/slack/block_kit/block/actions_block.rb', line 10

def self.populate(hash, object)
  hash[:elements].each(&object.elements.method(:<<))
end

Instance Method Details

#to_hObject



27
28
29
30
31
# File 'lib/slack/block_kit/block/actions_block.rb', line 27

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

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/slack/block_kit/block/actions_block.rb', line 23

def valid?
  !@elements.empty? && @elements.size <= 5
end