Class: Dry::Configurable::NestedConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/configurable/nested_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ NestedConfig

Returns a new instance of NestedConfig.



5
6
7
8
9
# File 'lib/dry/configurable/nested_config.rb', line 5

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



24
25
26
# File 'lib/dry/configurable/nested_config.rb', line 24

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

Instance Method Details

#create_configObject



12
13
14
15
16
# File 'lib/dry/configurable/nested_config.rb', line 12

def create_config
  if @klass.instance_variables.include?(:@_config)
    @klass.__send__(:create_config)
  end
end