Class: QuickSearch::Adapters::MongoidAdapter
- Inherits:
-
Object
- Object
- QuickSearch::Adapters::MongoidAdapter
- Defined in:
- lib/quick-search/adapters/mongoid_adapter.rb
Instance Method Summary collapse
- #default_quick_search_fields ⇒ Object
-
#initialize(cls) ⇒ MongoidAdapter
constructor
A new instance of MongoidAdapter.
- #make_clauses_for_token(s, token, fields) ⇒ Object
Constructor Details
#initialize(cls) ⇒ MongoidAdapter
Returns a new instance of MongoidAdapter.
4 5 6 |
# File 'lib/quick-search/adapters/mongoid_adapter.rb', line 4 def initialize(cls) @cls = cls end |
Instance Method Details
#default_quick_search_fields ⇒ Object
12 13 14 |
# File 'lib/quick-search/adapters/mongoid_adapter.rb', line 12 def default_quick_search_fields @cls.fields.select { |_, f| f.type == String }.map(&:first) end |
#make_clauses_for_token(s, token, fields) ⇒ Object
8 9 10 |
# File 'lib/quick-search/adapters/mongoid_adapter.rb', line 8 def make_clauses_for_token(s, token, fields) s.and '$or' => fields.map { |f| { to_field_name(f) => /#{Regexp.escape token}/i } } end |