Sha256: 3d35cb286f2ba8c1d9172bf7172ffb9b05dd62cbaeefffc7a4b49335b6cf5104

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require "hanami/assets/configuration"
require "dry/configurable"

module Hanami
  module Assets
    # @since 2.0.0
    # @api public
    class ApplicationConfiguration
      include Dry::Configurable

      # @since 2.0.0
      # @api private
      attr_reader :base_configuration
      protected :base_configuration

      setting :server_url, default: "http://localhost:8080"

      # @since 2.0.0
      # @api private
      def initialize(*)
        super

        @base_configuration = Assets::Configuration.new
      end

      def initialize_copy(source)
        super
        @base_configuration = source.base_configuration.dup
      end

      # @since 2.0.0
      # @api private
      def finalize!
      end

      # Returns the list of available settings
      #
      # @return [Set]
      #
      # @since 2.0.0
      # @api private
      def settings
        base_configuration.settings + self.class.settings
      end

      private

      # @since 2.0.0
      # @api private
      def method_missing(name, *args, &block)
        if config.respond_to?(name)
          config.public_send(name, *args, &block)
        elsif base_configuration.respond_to?(name)
          base_configuration.public_send(name, *args, &block)
        else
          super
        end
      end

      # @since 2.0.0
      # @api private
      def respond_to_missing?(name, _incude_all = false)
        config.respond_to?(name) || base_configuration.respond_to?(name) || super
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.0.0.beta1.1 lib/hanami/assets/application_configuration.rb
hanami-2.0.0.beta1 lib/hanami/assets/application_configuration.rb