Class: MongoSearch::Matchers::PartialMatcher
- Inherits:
-
Object
- Object
- MongoSearch::Matchers::PartialMatcher
- Defined in:
- lib/mongo-search/matchers/partial_matcher.rb
Instance Method Summary collapse
- #call(params) ⇒ Object
-
#initialize(attr) ⇒ PartialMatcher
constructor
A new instance of PartialMatcher.
Constructor Details
#initialize(attr) ⇒ PartialMatcher
Returns a new instance of PartialMatcher.
4 5 6 |
# File 'lib/mongo-search/matchers/partial_matcher.rb', line 4 def initialize(attr) @attr = attr end |
Instance Method Details
#call(params) ⇒ Object
8 9 10 11 12 |
# File 'lib/mongo-search/matchers/partial_matcher.rb', line 8 def call(params) filters = {} filters[@attr] = /#{Regexp.escape(params[@attr])}/i if params[@attr] && !params[@attr].empty? filters end |