Module: ROM::Configurable::ConfigMethods Private

Includes:
Enumerable
Included in:
Config
Defined in:
lib/rom/support/configurable.rb

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

Instance Method Summary collapse

Instance Method Details

#_constructorsObject

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.



135
136
137
# File 'lib/rom/support/configurable.rb', line 135

def _constructors
  @_constructors ||= _settings.map { |setting| [setting.name, setting.constructor] }.to_h
end

#each(&block) ⇒ 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.



59
60
61
# File 'lib/rom/support/configurable.rb', line 59

def each(&block)
  values.each(&block)
end

#empty?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)


103
104
105
# File 'lib/rom/support/configurable.rb', line 103

def empty?
  values.compact.empty?
end

#fetchObject

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.



118
119
120
# File 'lib/rom/support/configurable.rb', line 118

def fetch(...)
  values.fetch(...)
end

#freezeObject

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.



129
130
131
132
# File 'lib/rom/support/configurable.rb', line 129

def freeze
  _constructors
  super
end

#inherit(other) ⇒ 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.



69
70
71
72
73
74
75
76
77
78
# File 'lib/rom/support/configurable.rb', line 69

def inherit(other)
  hash = values.merge(other.to_h.slice(*keys)) { |key, left, right|
    if _constructors[key].is_a?(Constructors::Inherit)
      _constructors[key].(left, right)
    else
      left.nil? ? right : left
    end
  }
  merge(hash)
end

#inherit!(other) ⇒ 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.



64
65
66
# File 'lib/rom/support/configurable.rb', line 64

def inherit!(other)
  update(inherit(other))
end

#join(other, direction = :left) ⇒ 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.



86
87
88
89
90
91
92
93
94
95
# File 'lib/rom/support/configurable.rb', line 86

def join(other, direction = :left)
  hash = values.merge(other.to_h.slice(*keys)) { |key, left, right|
    if _constructors[key].is_a?(Constructors::Join)
      _constructors[key].(left, right, direction)
    else
      direction == :left ? left : right
    end
  }
  merge(hash)
end

#join!(other, direction = :left) ⇒ 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.



81
82
83
# File 'lib/rom/support/configurable.rb', line 81

def join!(other, direction = :left)
  update(join(other, direction))
end

#key?(key) ⇒ 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)


108
109
110
# File 'lib/rom/support/configurable.rb', line 108

def key?(key)
  _settings.key?(key)
end

#keysObject

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.



113
114
115
# File 'lib/rom/support/configurable.rb', line 113

def keys
  _settings.keys
end

#merge(other) ⇒ 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.



98
99
100
# File 'lib/rom/support/configurable.rb', line 98

def merge(other)
  dup.update(values.merge(other))
end

#to_hObject Also known as: to_hash

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.



123
124
125
# File 'lib/rom/support/configurable.rb', line 123

def to_h
  values
end