RS, IZ; Replace type_name method with object.class.to_s

This commit is contained in:
Raphael 2010-08-04 16:36:08 -07:00
parent b8a2e8ecdf
commit 2388237174

View file

@ -6,7 +6,7 @@ class Retraction
retraction = self.new
retraction.post_id= object.id
retraction.person_id = person_id_from(object)
retraction.type = self.type_name(object)
retraction.type = object.class.to_s
retraction
end
@ -19,7 +19,11 @@ class Retraction
attr_accessor :type
def perform
self.type.constantize.destroy(self.post_id)
begin
self.type.constantize.destroy(self.post_id)
rescue NameError
Rails.logger.info("Retraction for unknown type recieved.")
end
end
def self.person_id_from(object)
@ -30,15 +34,4 @@ class Retraction
end
end
def self.type_name(object)
if object.is_a? Post
object.class
elsif object.is_a? Person
'Person'
else
'Clowntown'
end
end
end