Class: BlockKit::Layout::Context
- Inherits:
-
Base
- Object
- Base
- Base
- BlockKit::Layout::Context
show all
- Defined in:
- lib/block_kit/layout/context.rb
Constant Summary
collapse
- MAX_ELEMENTS =
10
- SUPPORTED_ELEMENTS =
[
Elements::Image,
Composition::Mrkdwn,
Composition::PlainText
].freeze
Constants inherited
from Base
Base::MAX_BLOCK_ID_LENGTH
Instance Method Summary
collapse
Methods inherited from Base
inherited, #initialize
Methods inherited from Base
#==, fix, #fix_validation_errors, #fix_validation_errors!, fixes, inherited, #initialize, inspect, #inspect, #pretty_print, #to_json
Instance Method Details
#append(element) ⇒ Object
30
31
32
33
34
|
# File 'lib/block_kit/layout/context.rb', line 30
def append(element)
elements << element
self
end
|
#as_json ⇒ Object
36
37
38
|
# File 'lib/block_kit/layout/context.rb', line 36
def as_json(*)
super.merge(elements: elements&.map(&:as_json)).compact
end
|
#image(alt_text:, image_url: nil, slack_file: nil) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/block_kit/layout/context.rb', line 22
def image(alt_text:, image_url: nil, slack_file: nil)
if (image_url.nil? && slack_file.nil?) || (image_url && slack_file)
raise ArgumentError, "Must provide either image_url or slack_file, but not both."
end
append(Elements::Image.new(alt_text: alt_text, image_url: image_url, slack_file: slack_file))
end
|