Class: Dry::Configurable::Extension Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_class: Configurable::Config, default_undefined: false) ⇒ Extension

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Extension.



13
14
15
16
17
18
# File 'lib/dry/configurable/extension.rb', line 13

def initialize(config_class: Configurable::Config, default_undefined: false)
  super()
  @config_class = config_class
  @default_undefined = default_undefined
  freeze
end

Instance Attribute Details

#config_classObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/dry/configurable/extension.rb', line 7

def config_class
  @config_class
end

#default_undefinedObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/dry/configurable/extension.rb', line 10

def default_undefined
  @default_undefined
end

Instance Method Details

#extended(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
# File 'lib/dry/configurable/extension.rb', line 21

def extended(klass)
  super
  klass.extend(ClassMethods)
  klass.instance_variable_set(:@__config_extension__, self)
end

#included(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dry/configurable/extension.rb', line 28

def included(klass)
  super

  klass.class_eval do
    extend(ClassMethods)
    include(InstanceMethods)
    prepend(Initializer)

    class << self
      undef :config if method_defined?(:config)
      undef :configure if method_defined?(:configure)
    end
  end

  klass.instance_variable_set(:@__config_extension__, self)
end