class Tire::Suggest::PhraseSuggester

Used to generate phrase suggestions

Public Class Methods

new(field, options={}, &block) click to toggle source
# File lib/tire/suggest/suggestion.rb, line 46
def initialize(field, options={}, &block)
  @options = options
  @value   = { :field => field }
  block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given?
end

Public Instance Methods

generator(field, options={}) click to toggle source
# File lib/tire/suggest/suggestion.rb, line 52
def generator(field, options={})
  @generators ||= []
  @generators << { :field => field }.update(options).to_hash
  self
end
smoothing(type, options={}) click to toggle source
# File lib/tire/suggest/suggestion.rb, line 58
def smoothing(type, options={})
  @value[:smoothing] = { type => options }
end
to_hash() click to toggle source
# 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={}) click to toggle source
# File lib/tire/suggest/suggestion.rb, line 62
def to_json(options={})
  to_hash.to_json
end