Class: Mincer::Processors::Search
- Inherits:
-
Object
- Object
- Mincer::Processors::Search
- Defined in:
- lib/mincer/processors/search.rb
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(mincer) ⇒ Search
constructor
A new instance of Search.
- #textacular? ⇒ Boolean
Constructor Details
#initialize(mincer) ⇒ Search
Returns a new instance of Search.
4 5 6 |
# File 'lib/mincer/processors/search.rb', line 4 def initialize(mincer) @mincer, @args, @relation = mincer, mincer.args, mincer.relation end |
Instance Method Details
#apply ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mincer/processors/search.rb', line 8 def apply if Mincer.postgres? && !textacular? warn 'You must include "textacular" to your Gemfile to use search' @relation elsif Mincer.postgres? && @args['pattern'].present? @relation.basic_search(@args['pattern']).presence || @relation.fuzzy_search(@args['pattern']) else @relation end end |
#textacular? ⇒ Boolean
19 20 21 |
# File 'lib/mincer/processors/search.rb', line 19 def textacular? defined?(::Textacular) end |