Sha256: 183363ba693ed0babe8f59be1d6b268d0a3757666534987a0777a09182c68618

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Element
      # An interactive element that inserts a button.
      # The button can be a trigger for anything from opening a simple link
      # to starting a complex workflow.
      #
      # https://api.slack.com/reference/messaging/block-elements#button
      class Button
        include Composition::ConfirmationDialog::Confirmable

        TYPE = 'button'

        def initialize(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil)
          @text = Composition::PlainText.new(text: text, emoji: emoji)
          @action_id = action_id
          @url = url
          @style = style
          @value = value

          yield(self) if block_given?
        end

        def as_json(*)
          {
            type: TYPE,
            text: @text.as_json,
            action_id: @action_id,
            url: @url,
            value: @value,
            style: @style,
            confirm: confirm&.as_json
          }.compact
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.24.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.23.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.22.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.21.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.20.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.19.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.18.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.17.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.16.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.15.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.14.1 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.14.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.13.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.12.0 lib/slack/block_kit/element/button.rb
slack-ruby-block-kit-0.11.0 lib/slack/block_kit/element/button.rb