Sha256: 4c2e3e78b56b8fac622f118ebf79dcd80dcb1d8ac855350c19d32d4f2d0c77e0

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require "dry/configurable"
require_relative "../slice/routing/resolver"

module Hanami
  class Configuration
    # Hanami router configuration
    #
    # @since 2.0.0
    # @api private
    class Router
      include Dry::Configurable

      # Base configuration is provided so router config can include the `base_url`
      attr_reader :base_configuration
      private :base_configuration

      # @api private
      # @since 2.0.0
      def initialize(base_configuration)
        @base_configuration = base_configuration
      end

      setting :resolver, default: Slice::Routing::Resolver

      # @api private
      # @since 2.0.0
      def options
        {base_url: base_configuration.base_url}
      end

      private

      def method_missing(name, *args, &block)
        if config.respond_to?(name)
          config.public_send(name, *args, &block)
        else
          super
        end
      end

      def respond_to_missing?(name, _include_all = false)
        config.respond_to?(name) || super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-2.0.0.beta3 lib/hanami/configuration/router.rb
hanami-2.0.0.beta2 lib/hanami/configuration/router.rb
hanami-2.0.0.beta1.1 lib/hanami/configuration/router.rb
hanami-2.0.0.beta1 lib/hanami/configuration/router.rb