Skip to content

Commit

Permalink
Resolve class and find or raise for Mongoid objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryckbost committed Oct 24, 2011
1 parent fdd72bd commit ef5f7e4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/delayed/psych_ext.rb
Expand Up @@ -49,6 +49,14 @@ def visit_Psych_Nodes_Mapping_with_class(object)
rescue ActiveRecord::RecordNotFound
raise Delayed::DeserializationError
end
when /^!ruby\/Mongoid:(.+)$/
klass = resolve_class($1)
payload = Hash[*object.children.map { |c| accept c }]
begin
klass.find(payload["attributes"]["_id"])
rescue Mongoid::Errors::DocumentNotFound
raise Delayed::DeserializationError
end
else
visit_Psych_Nodes_Mapping_without_class(object)
end
Expand Down

0 comments on commit ef5f7e4

Please sign in to comment.