Sha256: 8735628c4293517a8c678e204890a68f16b3f903ce22f86bff6e6345e6c58b03
Contents?: true
Size: 1008 Bytes
Versions: 1
Compression:
Stored size: 1008 Bytes
Contents
# frozen_string_literal: true module Slack module BlockKit class Element class OverflowElement < Element using Refinements::HashCompact attr_reader :options, :confirm 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 def initialize @options = TypeRestrictedArray.new(CompositionObjects::Option) end def valid? (2..5).include?(options.size) end def confirm=(obj) unless obj.is_a?(CompositionObjects::ConfirmationDialog) raise TypeError, 'confirm must be a ConfirmationDialog Object' end @confirm = obj end def to_h super.merge( options: options.map(&:to_h), confirm: confirm&.to_h ).compact end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-block-kit-0.1.0 | lib/slack/block_kit/element/overflow_element.rb |