Sha256: 81c76d3174b96e2086469597df29297a4ba3c52a718214a9af6b27001e3055d0
Contents?: true
Size: 959 Bytes
Versions: 67
Compression:
Stored size: 959 Bytes
Contents
# frozen_string_literal: true require "active_support/concern" module Primer # :nodoc: module Status # DSL to allow components to register their status. # # Example: # # class MyComponent < ViewComponent::Base # include Primer::Status::Dsl # status :beta # end module Dsl extend ActiveSupport::Concern STATUSES = { alpha: :alpha, beta: :beta, stable: :stable, deprecated: :deprecated }.freeze class UnknownStatusError < StandardError; end included do class_attribute :component_status, instance_writer: false, default: STATUSES[:alpha] 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
67 entries across 67 versions & 1 rubygems