Class: Slack::BlockKit::Block::ActionsBlock
- Inherits:
-
Slack::BlockKit::Block
- Object
- Slack::BlockKit::Block
- Slack::BlockKit::Block::ActionsBlock
- Defined in:
- lib/slack/block_kit/block/actions_block.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
Attributes inherited from Slack::BlockKit::Block
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ActionsBlock
constructor
A new instance of ActionsBlock.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Slack::BlockKit::Block
Constructor Details
#initialize ⇒ ActionsBlock
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
#elements ⇒ Object
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_h ⇒ Object
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
23 24 25 |
# File 'lib/slack/block_kit/block/actions_block.rb', line 23 def valid? !@elements.empty? && @elements.size <= 5 end |