Sha256: 19900870dddbe7abf75a6e1abdbac3ca76622b1545d5822b10105dfd73b35768

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    class Element
      class ConversationsSelectElement < SelectElement
        using Refinements::HashCompact
        attr_reader :initial_conversation, :response_url_enabled, :filter
        attr_writer :initial_conversation

        def self.populate(hash, object)
          if hash.key?(:initial_conversation)
            object.initial_conversation = hash[:initial_conversation]
          end
          object.response_url_enabled! if hash.key?(:response_url_enabled)
          object.filter = hash[:filter] if hash.key?(:filter)

          super(hash, object)
        end

        def response_url_enabled!
          @response_url_enabled = true
        end

        def filter=(obj)
          unless obj.is_a?(CompositionObjects::Filter)
            raise TypeError, 'confirm must be a Filter Object'
          end

          @filter = obj
        end

        def to_h
          super.merge(
            initial_conversation: initial_conversation,
            response_url_enabled: response_url_enabled,
            filter: filter&.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/conversations_select_element.rb