14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/acts_as_caesar/modules/act_as_candidate.rb', line 14
def self.handle_candidate_update_notification(base, candidate)
unless candidate.key =~ /\_([\da-f]+)$/ && id = $1
raise ArgumentError, "#{candidate.key} does not contain a valid key"
end
if ActiveRecordPersistence.can_handle?(base)
ActiveRecordPersistence.new(base, id).update_score
elsif MongoidPersistence.can_handle?(base)
MongoidPersistence.new(base, id).update_score
elsif base.respond_to?(:acts_as_caesar_score_persistence)
base.acts_as_caesar_score_persistence.new(base, id).update_score
else
raise StandardError, %Q(
Incompatible database adapter, try implementing the following method:
def self.acts_as_caesar_score_persistence
# returns a class name like lib/acts_as_caesar/services/mongoid_persistence.rb
# e.g. MongoidPersistence
end
)
end
end
|