Module: Mongoid::Matchers::Strategies
Overview
This module is responsible for returning the correct matcher given a MongoDB query expression.
Constant Summary collapse
- MATCHERS =
{ "$all" => Matchers::All, "$exists" => Matchers::Exists, "$gt" => Matchers::Gt, "$gte" => Matchers::Gte, "$in" => Matchers::In, "$lt" => Matchers::Lt, "$lte" => Matchers::Lte, "$ne" => Matchers::Ne, "$nin" => Matchers::Nin, "$or" => Matchers::Or, "$size" => Matchers::Size }
Instance Method Summary collapse
-
#matcher(document, key, value) ⇒ Matcher
Get the matcher for the supplied key and value.
Instance Method Details
#matcher(document, key, value) ⇒ Matcher
Get the matcher for the supplied key and value. Will determine the class name from the key.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mongoid/matchers/strategies.rb', line 50 def matcher(document, key, value) if value.is_a?(Hash) MATCHERS[value.keys.first].new(document.attributes[key.to_s]) else if key == "$or" Matchers::Or.new(value, document) else Default.new(document.attributes[key.to_s]) end end end |