Class: MongoSearch::Matchers::GreaterThanMatcher
- Inherits:
-
Object
- Object
- MongoSearch::Matchers::GreaterThanMatcher
- Defined in:
- lib/mongo-search/matchers/greater_than_matcher.rb
Instance Method Summary collapse
- #call(params) ⇒ Object
-
#initialize(attr, opts = nil) ⇒ GreaterThanMatcher
constructor
A new instance of GreaterThanMatcher.
Constructor Details
#initialize(attr, opts = nil) ⇒ GreaterThanMatcher
Returns a new instance of GreaterThanMatcher.
4 5 6 7 8 9 10 |
# File 'lib/mongo-search/matchers/greater_than_matcher.rb', line 4 def initialize(attr, opts = nil) opts ||= {} @attr = attr @field = opts[:field] || attr @operator = opts[:equal] ? :$gte : :$gt @conv = Converters[opts[:type]] end |
Instance Method Details
#call(params) ⇒ Object
12 13 14 15 16 |
# File 'lib/mongo-search/matchers/greater_than_matcher.rb', line 12 def call(params) filters = {} filters[@field] = {@operator => @conv.call(params[@attr])} if params[@attr] && !params[@attr].empty? filters end |