Class: ROM::Configurable::Config Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/support/configurable.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.

Constant Summary collapse

WRITER_REGEXP =

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

/=$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ Config

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 Config.



17
18
19
# File 'lib/rom/support/configurable.rb', line 17

def initialize(settings = {})
  @settings = settings
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object (private)

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.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rom/support/configurable.rb', line 52

def method_missing(meth, *args, &)
  return settings.fetch(meth, nil) if frozen?

  name = meth.to_s
  key = name.gsub(WRITER_REGEXP, '').to_sym

  if writer?(name)
    settings[key] = args.first
  else
    settings.fetch(key) { settings[key] = self.class.new }
  end
end

Instance Attribute Details

#settingsObject (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.



14
15
16
# File 'lib/rom/support/configurable.rb', line 14

def settings
  @settings
end

Instance Method Details

#[](name) ⇒ Mixed

Return a setting



26
# File 'lib/rom/support/configurable.rb', line 26

def [](name) = public_send(name)

#dupObject

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.



37
# File 'lib/rom/support/configurable.rb', line 37

def dup = self.class.new(dup_settings(settings))

#key?(name) ⇒ Boolean

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.



29
# File 'lib/rom/support/configurable.rb', line 29

def key?(name) = settings.key?(name)

#respond_to_missing?(_name, _include_private = false) ⇒ Boolean

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.



34
# File 'lib/rom/support/configurable.rb', line 34

def respond_to_missing?(_name, _include_private = false) = true

#to_hashObject

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.



31
# File 'lib/rom/support/configurable.rb', line 31

def to_hash = settings