Sha256: 10aef206b4cdcc0c1c44f73ac1a4b728958b2290ad45d12edf6ff353f80e6946

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

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

module Hanami
  class Config
    # Hanami router config
    #
    # @since 2.0.0
    # @api private
    class Router
      include Dry::Configurable

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

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

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

      # @api private
      # @since 2.0.0
      def options
        {base_url: base_config.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

1 entries across 1 versions & 1 rubygems

Version Path
hanami-2.0.0.beta4 lib/hanami/config/router.rb