Permalink
Browse files

Revert serialization refactoring that had some major issues

This reverts commit cbde340.
  • Loading branch information...
1 parent f99439a commit ffd1173e07b4e31ccb66a685391e70a831501367 @bkeepers bkeepers committed Nov 15, 2010
Showing with 10 additions and 21 deletions.
  1. +1 −1 lib/delayed/backend/base.rb
  2. +7 −12 lib/delayed/serialization/active_record.rb
  3. +2 −8 lib/delayed/yaml_ext.rb
View
2 lib/delayed/backend/base.rb
@@ -68,7 +68,7 @@ def name
def payload_object=(object)
@payload_object = object
- self.handler = object.to_delayed_yaml
+ self.handler = object.to_yaml
end
def payload_object
View
19 lib/delayed/serialization/active_record.rb
@@ -1,18 +1,13 @@
class ActiveRecord::Base
- def to_delayed_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
- out.map("tag:delayed_job.com,2010:ActiveRecord:#{self.class.name}", to_yaml_style) do |map|
- map.add('id', id)
- end
- end
- end
-end
+ yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"
-YAML.add_domain_type('delayed_job.com,2010', 'ActiveRecord') do |tag, value|
- begin
- type, model = YAML.read_type_class(tag, Kernel)
- model.find(value['id'])
+ def self.yaml_new(klass, tag, val)
+ klass.find(val['attributes']['id'])
rescue ActiveRecord::RecordNotFound
raise Delayed::DeserializationError
end
+
+ def to_yaml_properties
+ ['@attributes']
+ end
end
View
10 lib/delayed/yaml_ext.rb
@@ -15,14 +15,14 @@ def to_yaml( opts = {} )
out.scalar(taguri, self.name, :plain)
}
end
-
+
def yaml_tag_read_class(name)
# Constantize the object so that ActiveSupport can attempt
# its auto loading magic. Will raise LoadError if not successful.
name.constantize
name
end
-
+
end
class Class
@@ -38,9 +38,3 @@ def self.yaml_tag_read_class(name)
"Struct::#{ name }"
end
end
-
-class Object
- def to_delayed_yaml
- to_yaml
- end
-end

0 comments on commit ffd1173

Please sign in to comment.