Sha256: 47748ecc205ee926808bd58a065c1ace1898b897c7562f8c1432f36f4b7edc26

Contents?: true

Size: 617 Bytes

Versions: 1

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    class Block
      class ContextBlock < Block
        using Refinements::HashCompact
        attr_accessor :elements

        def self.populate(hash, object)
          hash[:elements].each(&object.elements.method(:<<))
        end

        def initialize
          @elements = TypeRestrictedArray.new(Element, CompositionObjects::Text)
        end

        def valid?
          !@elements.empty?
        end

        def to_h
          super.merge(
            elements: elements.map(&: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/block/context_block.rb