Module: Mongoid::Extensions::Hash::CriteriaHelpers
- Included in:
- Hash
- Defined in:
- lib/mongoid/extensions/hash/criteria_helpers.rb
Overview
Expands complex criterion into mongodb selectors.
Instance Method Summary collapse
-
#expand_complex_criteria ⇒ Hash
Expand the complex criteria into a MongoDB compliant selector hash.
Instance Method Details
#expand_complex_criteria ⇒ Hash
Expand the complex criteria into a MongoDB compliant selector hash.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mongoid/extensions/hash/criteria_helpers.rb', line 17 def {}.tap do |hsh| each_pair do |k,v| case k when Mongoid::Criterion::Complex hsh[k.key] ||= {} hsh[k.key].merge!({"$#{k.operator}" => v}) else hsh[k] = v end end end end |