Module: Soulmate
- Extended by:
- Soulmate
- Included in:
- Soulmate
- Defined in:
- lib/soulmate/base.rb,
lib/soulmate_rails.rb,
lib/soulmate/loader.rb,
lib/soulmate/helpers.rb,
lib/soulmate/matcher.rb
Defined Under Namespace
Modules: Helpers
Classes: Base, Loader, Matcher
Constant Summary
collapse
- MIN_COMPLETE =
2
- DEFAULT_STOP_WORDS =
["vs", "at", "the"]
Instance Method Summary
collapse
Instance Method Details
#cache_namespace ⇒ Object
76
77
78
|
# File 'lib/soulmate_rails.rb', line 76
def cache_namespace
@cache_namespace
end
|
#cache_namespace=(namespace) ⇒ Object
80
81
82
|
# File 'lib/soulmate_rails.rb', line 80
def cache_namespace=(namespace)
@cache_namespace = namespace
end
|
#cache_time ⇒ Object
65
66
67
68
|
# File 'lib/soulmate_rails.rb', line 65
def cache_time
@cache_time ||= 10 * 60
end
|
#cache_time=(time_period) ⇒ Object
70
71
72
73
74
|
# 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 ⇒ Object
84
85
86
87
|
# File 'lib/soulmate_rails.rb', line 84
def max_results
@max_results ||= 10
end
|
#max_results=(max_num) ⇒ Object
89
90
91
92
93
|
# 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 ⇒ Object
55
56
57
|
# File 'lib/soulmate_rails.rb', line 55
def min_complete
@min_complete ||= MIN_COMPLETE
end
|
#min_complete=(min_len) ⇒ Object
59
60
61
62
63
|
# 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 ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# 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 ⇒ Object
47
48
49
|
# File 'lib/soulmate_rails.rb', line 47
def stop_words
@stop_words ||= DEFAULT_STOP_WORDS
end
|
#stop_words=(arr) ⇒ Object
51
52
53
|
# File 'lib/soulmate_rails.rb', line 51
def stop_words=(arr)
@stop_words = Array(arr).flatten
end
|