Class: QuickSearch::Adapters::ActiveRecordAdapter
- Inherits:
-
Object
- Object
- QuickSearch::Adapters::ActiveRecordAdapter
- Defined in:
- lib/quick-search/adapters/active_record_adapter.rb
Instance Method Summary collapse
- #default_quick_search_fields ⇒ Object
-
#initialize(cls) ⇒ ActiveRecordAdapter
constructor
A new instance of ActiveRecordAdapter.
- #make_clauses_for_token(s, token, fields) ⇒ Object
Constructor Details
#initialize(cls) ⇒ ActiveRecordAdapter
Returns a new instance of ActiveRecordAdapter.
4 5 6 |
# File 'lib/quick-search/adapters/active_record_adapter.rb', line 4 def initialize(cls) @cls = cls end |
Instance Method Details
#default_quick_search_fields ⇒ Object
15 16 17 |
# File 'lib/quick-search/adapters/active_record_adapter.rb', line 15 def default_quick_search_fields @cls.columns.select { |c| c.type == :string }.map(&:name) end |
#make_clauses_for_token(s, token, fields) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/quick-search/adapters/active_record_adapter.rb', line 8 def make_clauses_for_token(s, token, fields) s = s.joins calculate_needed_joins(fields) s = s.where build_parameterized_condition(fields, :s), s: "%#{token}%" s end |