Sha256: aa72cda64bcf3e5ff7a2a0212154a28e25b40607d9b9254f52bb00ddd16c8af6

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 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

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

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

        @base_configuration = Assets::Configuration.new
      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
      attr_reader :base_configuration

      # @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

6 entries across 6 versions & 1 rubygems

Version Path
hanami-2.0.0.alpha8 lib/hanami/assets/application_configuration.rb
hanami-2.0.0.alpha7.1 lib/hanami/assets/application_configuration.rb
hanami-2.0.0.alpha7 lib/hanami/assets/application_configuration.rb
hanami-2.0.0.alpha6 lib/hanami/assets/application_configuration.rb
hanami-2.0.0.alpha5 lib/hanami/assets/application_configuration.rb
hanami-2.0.0.alpha4 lib/hanami/assets/application_configuration.rb