29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/riaction/riaction.rb', line 29
def self.perform(klass_name, id, attempt=0)
if klass_name.constantize.riaction_profile?
iactionable_api = IActionable::Api.new
profile_object = klass_name.constantize.find_by_id!(id)
profile_keys = profile_object.riaction_profile_keys
iactionable_api.create_profile(profile_keys[:profile_type], profile_keys[:id_type], profile_keys[:id])
else
raise NoProfileDefined.new
end
rescue ActiveRecord::RecordNotFound => e
rescue IActionable::Error::BadRequest => e
raise e
rescue IActionable::Error::Internal => e
if attempt < Riaction.retry_attempts_for_internal_error
Resque.enqueue(Riaction::ProfileCreator, klass_name, id, attempt+1)
else
raise e
end
end
|