Class: ROM::Configurable::Config Private

Inherits:
Object
  • Object
show all
Defined in:
core/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.

/=$/.freeze

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 'core/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, &_block) ⇒ 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.



62
63
64
65
66
67
68
69
70
71
72
73
# File 'core/lib/rom/support/configurable.rb', line 62

def method_missing(meth, *args, &_block)
  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 'core/lib/rom/support/configurable.rb', line 14

def settings
  @settings
end

Instance Method Details

#[](name) ⇒ Mixed

Return a setting

Returns:

  • (Mixed)


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

def [](name)
  public_send(name)
end

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



45
46
47
# File 'core/lib/rom/support/configurable.rb', line 45

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

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

Returns:

  • (Boolean)


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

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

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

Returns:

  • (Boolean)


40
41
42
# File 'core/lib/rom/support/configurable.rb', line 40

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

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



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

def to_hash
  settings
end