Class: Mongory::Converters::Converted::Hash

Inherits:
Hash
  • Object
show all
Includes:
Mongory::Converters::Converted
Defined in:
lib/mongory/converters/converted.rb

Overview

Converts a flat condition hash into a nested structure. Applies value conversion to each element. This is used for conditions that are hashes of values. It is used internally by the ConditionConverter and ValueConverter to handle the conversion of complex data types into a format suitable for MongoDB queries.

Instance Method Summary collapse

Methods included from Mongory::Converters::Converted

#instance_convert

Constructor Details

#initialize(other = {}) ⇒ Hash

Returns a new instance of Hash.



35
36
37
38
39
40
# File 'lib/mongory/converters/converted.rb', line 35

def initialize(other = {})
  super()
  other.each_pair do |k, v|
    self[k] = instance_convert(v)
  end
end

Instance Method Details

#deep_merge(other) ⇒ Object



42
43
44
# File 'lib/mongory/converters/converted.rb', line 42

def deep_merge(other)
  dup.deep_merge!(Hash.new(other))
end

#deep_merge!(other) ⇒ Object



46
47
48
# File 'lib/mongory/converters/converted.rb', line 46

def deep_merge!(other)
  _deep_merge!(self, Hash.new(other))
end