Module: Mongrep::Model::VirtusExtensions
- Included in:
- Mongrep::Model
- Defined in:
- lib/mongrep/model.rb
Overview
Extensions to Virtus models
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Checks for equality between self and other.
-
#to_h ⇒ Hash
Converts the model into a hash.
Instance Method Details
#==(other) ⇒ true, false
Checks for equality between self and other
124 125 126 127 |
# File 'lib/mongrep/model.rb', line 124 def ==(other) return false unless other.is_a?(self.class) to_h == other.to_h end |
#to_h ⇒ Hash
Converts the model into a hash. This supports nested models.
114 115 116 117 118 |
# File 'lib/mongrep/model.rb', line 114 def to_h result = {} super.each { |key, value| result[key] = hashify_value(value) } result end |