6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/redis/autosuggest/rails/sources.rb', line 6
def autosuggest(column, options={})
hash = Redis::Autosuggest.rails_sources[self]
if hash.nil?
Redis::Autosuggest.rails_sources[self] = { column => options }
else
hash[column] = options
end
class_eval <<-HERE
after_create :add_to_autosuggest
def add_to_autosuggest
Redis::Autosuggest::SuggestRails.add_to_autosuggest(self)
end
after_update :check_if_changed
def check_if_changed
Redis::Autosuggest::SuggestRails.check_if_changed(self)
end
before_destroy :remove_from_autosuggest
def remove_from_autosuggest
Redis::Autosuggest::SuggestRails.remove_from_autosuggest(self)
end
HERE
end
|