Sha256: b6bf5884afd1a2c329cb7704712af7e872de0688771e0b7118839756672287af

Contents?: true

Size: 931 Bytes

Versions: 294

Compression:

Stored size: 931 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Ariadne
  # :nodoc:
  module Status
    # DSL to allow components to register their status.
    #
    # Example:
    #
    # class MyComponent < ViewComponent::Base
    #   include Ariadne::Status::Dsl
    #   status :experimental
    # end
    module Dsl
      extend ActiveSupport::Concern

      STATUSES = {
        experimental: :experimental,
        stable: :stable,
      }.freeze

      class UnknownStatusError < StandardError; end

      included do
        class_attribute :component_status, instance_writer: false, default: STATUSES[:stable]
      end

      class_methods do
        def status(status = nil)
          return component_status if status.nil?

          raise UnknownStatusError, "status #{status} does not exist" if STATUSES[status].nil?

          self.component_status = STATUSES[status]
        end
      end
    end
  end
end

Version data entries

294 entries across 294 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.13-x64-mingw32 app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.13-x64-mingw-ucrt app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.13-arm64-darwin app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.13-aarch64-linux app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12 app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12-x86_64-linux app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12-x86_64-darwin app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12-x64-mingw32 app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12-x64-mingw-ucrt app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12-arm64-darwin app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.12-aarch64-linux app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11 app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11-x86_64-linux app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11-x86_64-darwin app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11-x64-mingw32 app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11-x64-mingw-ucrt app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11-arm64-darwin app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.11-aarch64-linux app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.10 app/lib/ariadne/status/dsl.rb
ariadne_view_components-0.0.10-x86_64-linux app/lib/ariadne/status/dsl.rb