Sha256: 0a317208e2ac714fbca4cec953794c76a24c4100836d4c64f9a50b378bc0f03c

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

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

2 entries across 2 versions & 1 rubygems

Version Path
dry-configurable-0.7.0 lib/dry/configurable/nested_config.rb
dry-configurable-0.6.2 lib/dry/configurable/nested_config.rb