Module: LikeSearch::SearchMethods
- Defined in:
- lib/like_search.rb
Instance Method Summary collapse
Instance Method Details
#search(query) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/like_search.rb', line 25 def search(query) if query.present? where(format_search_sql, "%#{query}%") else scoped # TODO: test if only self works here end end |
#token_search(query, token_size = 2) ⇒ Object
33 34 35 36 37 |
# File 'lib/like_search.rb', line 33 def token_search(query, token_size=2) query.to_s.split.inject(scoped) do |current_scope, term| term.size > token_size ? current_scope.search(term) : current_scope end end |