Sha256: 11c74824a1555365a9b398e0dcacde6823f01f97fc5b2f955abde873b289fa00

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Layout
      class RichText
        module RichTextElements
          module StyleHelper
            def validate_styles(provided_styles, valid_styles)
              provided_styles.each do |style|
                raise ArgumentError, "Invalid style: #{style}. Valid styles: #{valid_styles}." unless valid_styles.include?(style)
              end
            end

            def styles_as_json(styles)
              return if styles.empty?

              styles.each_with_object({}) { |style, block| block[style] = true }
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 lib/slack/block_kit/layout/rich_text/rich_text_elements/style_helper.rb
slack-ruby-block-kit-0.24.0 lib/slack/block_kit/layout/rich_text/rich_text_elements/style_helper.rb