Class: Tire::Suggest::PhraseSuggester
- Inherits:
-
Object
- Object
- Tire::Suggest::PhraseSuggester
- Defined in:
- lib/tire/suggest/suggestion.rb
Overview
Used to generate phrase suggestions
Instance Method Summary collapse
- #generator(field, options = {}) ⇒ Object
-
#initialize(field, options = {}, &block) ⇒ PhraseSuggester
constructor
A new instance of PhraseSuggester.
- #smoothing(type, options = {}) ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(field, options = {}, &block) ⇒ PhraseSuggester
Returns a new instance of PhraseSuggester.
46 47 48 49 50 |
# File 'lib/tire/suggest/suggestion.rb', line 46 def initialize(field, ={}, &block) @options = @value = { :field => field } block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given? end |
Instance Method Details
#generator(field, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/tire/suggest/suggestion.rb', line 52 def generator(field, ={}) @generators ||= [] @generators << { :field => field }.update().to_hash self end |
#smoothing(type, options = {}) ⇒ Object
58 59 60 |
# File 'lib/tire/suggest/suggestion.rb', line 58 def smoothing(type, ={}) @value[:smoothing] = { type => } end |
#to_hash ⇒ Object
66 67 68 69 70 71 |
# File 'lib/tire/suggest/suggestion.rb', line 66 def to_hash @value.update(@options) @value.update( { :direct_generator => @generators } ) if @generators && @generators.size > 0 @value end |
#to_json(options = {}) ⇒ Object
62 63 64 |
# File 'lib/tire/suggest/suggestion.rb', line 62 def to_json(={}) to_hash.to_json end |