Class: Slack::BlockKit::Block::ContextBlock
- Inherits:
-
Slack::BlockKit::Block
- Object
- Slack::BlockKit::Block
- Slack::BlockKit::Block::ContextBlock
- Defined in:
- lib/slack/block_kit/block/context_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 ⇒ ContextBlock
constructor
A new instance of ContextBlock.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Slack::BlockKit::Block
Constructor Details
#initialize ⇒ ContextBlock
Returns a new instance of ContextBlock.
14 15 16 |
# File 'lib/slack/block_kit/block/context_block.rb', line 14 def initialize @elements = TypeRestrictedArray.new(Element, CompositionObjects::Text) end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
8 9 10 |
# File 'lib/slack/block_kit/block/context_block.rb', line 8 def elements @elements end |
Class Method Details
.populate(hash, object) ⇒ Object
10 11 12 |
# File 'lib/slack/block_kit/block/context_block.rb', line 10 def self.populate(hash, object) hash[:elements].each(&object.elements.method(:<<)) end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 |
# File 'lib/slack/block_kit/block/context_block.rb', line 22 def to_h super.merge( elements: elements.map(&:to_h) ).compact end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/slack/block_kit/block/context_block.rb', line 18 def valid? !@elements.empty? end |