module Soulmate

Constants

DEFAULT_STOP_WORDS
MIN_COMPLETE

Public Instance Methods

cache_namespace() click to toggle source
# File lib/soulmate_rails.rb, line 76
def cache_namespace
  @cache_namespace
end
cache_namespace=(namespace) click to toggle source
# File lib/soulmate_rails.rb, line 80
def cache_namespace=(namespace)
  @cache_namespace = namespace
end
cache_time() click to toggle source
# File lib/soulmate_rails.rb, line 65
def cache_time
  # default to 10 minutes
  @cache_time ||= 10 * 60
end
cache_time=(time_period) click to toggle source
# File lib/soulmate_rails.rb, line 70
def cache_time=(time_period)
  if time_period.is_a? Integer
    @cache_time = time_period unless time_period < 1
  end
end
max_results() click to toggle source
# File lib/soulmate_rails.rb, line 84
def max_results
  # default to 10 max results returned
  @max_results ||= 10
end
max_results=(max_num) click to toggle source
# File lib/soulmate_rails.rb, line 89
def max_results=(max_num)
  if max_num.is_a? Integer
    @max_results = max_num unless max_num < 1
  end
end
min_complete() click to toggle source
# File lib/soulmate_rails.rb, line 55
def min_complete
  @min_complete ||= MIN_COMPLETE
end
min_complete=(min_len) click to toggle source
# File lib/soulmate_rails.rb, line 59
def min_complete=(min_len)
  if min_len.is_a? Integer
    @min_complete = min_len unless min_len < 1 || min_len > 5
  end
end
redis() click to toggle source
# File lib/soulmate_rails.rb, line 34
def redis
  @redis ||= (
    url = URI(@redis_url || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0")

    ::Redis.new({
      :host => url.host,
      :port => url.port,
      :db => url.path[1..-1],
      :password => url.password
    })
  )
end
redis=(server) click to toggle source
# File lib/soulmate_rails.rb, line 23
def redis=(server)
  if server.is_a?(String)
    @redis = nil
    @redis_url = server
  else
    @redis = server
  end

  redis
end
stop_words() click to toggle source
# File lib/soulmate_rails.rb, line 47
def stop_words
  @stop_words ||= DEFAULT_STOP_WORDS
end
stop_words=(arr) click to toggle source
# File lib/soulmate_rails.rb, line 51
def stop_words=(arr)
  @stop_words = Array(arr).flatten
end