Sha256: b42d8489546f783965ad03f0ed65eae15e9dd1016b4e647b69964d33ea2d91e6

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

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

module Hanami
  module Assets
    # @since 2.0.0
    # @api public
    class AppConfiguration
      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.beta3 lib/hanami/assets/app_configuration.rb
hanami-2.0.0.beta2 lib/hanami/assets/app_configuration.rb