Sha256: c396220901cf47cf7d6c4ba66abc0299e91f9dbd3e7872bfe41672e54954f9a0
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Slack module BlockKit class Element class SelectElement < Element attr_reader :placeholder, :confirm def self.populate(hash, object) object.placeholder = hash.fetch(:placeholder) object.confirm = hash[:confirm] if hash.key?(:confirm) super(hash, object) end def valid? !(@placeholder.nil? || @placeholder.empty?) end def placeholder=(obj) raise TypeError, 'placeholder must be a Text Object' unless obj.is_a?(CompositionObjects::Text) raise TypeError, 'placeholder must be plain_text' unless obj.type == :plain_text raise RangeError, 'placeholder is max 150 characters' unless obj.text.size <= 150 @placeholder = obj 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( placeholder: placeholder.to_h, confirm: confirm&.to_h ) 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/select_element.rb |