Sha256: 81d4f578e8d774d9ccc1ea7d066d609de5de558270dc89a329470f483651ba3f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module ::AmberComponent
  # Object which stores configuration options
  # for this gem.
  class Configuration
    # @return [Array<Symbol>]
    STIMULUS_INTEGRATIONS = %i[importmap jsbundling webpack esbuild rollup].freeze

    # How Stimulus.js is bundled in this app.
    # Possible values: `[nil, :importmap, :jsbundling, :webpack, :esbuild, :rollup]`
    # `nil` indicates that stimulus should not be used (default behaviour).
    #
    # @return [Symbol, nil]
    attr_reader :stimulus

    # How Stimulus.js is bundled in this app.
    # Possible values: `[nil, :importmap, :jsbundling, :webpack, :esbuild, :rollup]`
    # `nil` indicates that stimulus should not be used (default behaviour).
    #
    # @param val [Symbol, String, nil]
    def stimulus=(val)
      val = val&.to_sym
      unless val.nil? || STIMULUS_INTEGRATIONS.include?(val)
        raise(::ArgumentError,
              "Invalid value for `stimulus` bundling. " \
              "Received #{val.inspect}, expected one of #{STIMULUS_INTEGRATIONS.inspect}")
      end

      @stimulus = val
    end

    # @return [Boolean]
    def stimulus?
      !@stimulus.nil?
    end

    # @return [Boolean]
    def stimulus_importmap?
      @stimulus == :importmap
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amber_component-1.1.0 lib/amber_component/configuration.rb