Class: SearchRedux::Searchable
- Inherits:
-
Object
- Object
- SearchRedux::Searchable
- Defined in:
- lib/search_redux/searchable.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rank ⇒ Object
Returns the value of attribute rank.
Class Method Summary collapse
Instance Method Summary collapse
- #full_text_search(query, active_record_instance) ⇒ Object
-
#initialize(options = {}) ⇒ Searchable
constructor
A new instance of Searchable.
Constructor Details
#initialize(options = {}) ⇒ Searchable
Returns a new instance of Searchable.
16 17 18 19 20 |
# File 'lib/search_redux/searchable.rb', line 16 def initialize( = {}) = self.class..merge() @options = end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/search_redux/searchable.rb', line 5 def columns @columns end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/search_redux/searchable.rb', line 7 def @options end |
#rank ⇒ Object
Returns the value of attribute rank.
6 7 8 |
# File 'lib/search_redux/searchable.rb', line 6 def rank @rank end |
Class Method Details
.default_options ⇒ Object
9 10 11 12 13 14 |
# File 'lib/search_redux/searchable.rb', line 9 def self. @default_options ||= { :columns => %w(title content), :rank => 'title' } end |
Instance Method Details
#full_text_search(query, active_record_instance) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/search_redux/searchable.rb', line 22 def full_text_search(query, active_record_instance) if query.present? @options.merge! :query => query adapter = SearchRedux.db_adapter strategy = SearchRedux.select_best_query_strategy(adapter, @options) strategy.call(active_record_instance) else active_record_instance.scoped end end |