Sha256: e28e6079afa5b6a68b15ad397c21f64b8327ea77ed0bf8c0cf676aa162fd5d90

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

module Dry
  module Configurable
    # @private
    class NestedConfig
      def initialize(&block)
        klass = ::Class.new { extend ::Dry::Configurable }
        klass.instance_eval(&block)
        @klass = klass
      end

        # @private no, really...
      def create_config
        if @klass.instance_variables.include?(:@_config)
          @klass.__send__(:create_config)
        end
      end

      private

      def config
        @klass.config
      end

      def method_missing(method, *args, &block)
        config.respond_to?(method) ? config.public_send(method, *args, &block) : super
      end

      def respond_to_missing?(method, _include_private = false)
        config.respond_to?(method) || super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-configurable-0.6.1 lib/dry/configurable/nested_config.rb