Skip to content

Commit

Permalink
Move ActiveRecord serialization to syck_ext
Browse files Browse the repository at this point in the history
  • Loading branch information
bryckbost committed Sep 28, 2011
1 parent 34acf1e commit 79cce65
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
17 changes: 0 additions & 17 deletions lib/delayed/serialization/active_record.rb

This file was deleted.

18 changes: 18 additions & 0 deletions lib/delayed/syck_ext.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
class ActiveRecord::Base
yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"

def self.yaml_new(klass, tag, val)
if ActiveRecord::VERSION::MAJOR == 3
klass.unscoped.find(val['attributes'][klass.primary_key])
else # Rails 2
klass.with_exclusive_scope { klass.find(val['attributes'][klass.primary_key]) }
end
rescue ActiveRecord::RecordNotFound
raise Delayed::DeserializationError
end

def to_yaml_properties
['@attributes']
end
end

class Module
yaml_as "tag:ruby.yaml.org,2002:module"

Expand Down
1 change: 0 additions & 1 deletion lib/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
require File.dirname(__FILE__) + '/delayed/worker'
require File.dirname(__FILE__) + '/delayed/deserialization_error'
require File.dirname(__FILE__) + '/delayed/railtie' if defined?(Rails::Railtie)
require File.dirname(__FILE__) + '/delayed/serialization/active_record' if defined?(ActiveRecord)

Object.send(:include, Delayed::MessageSending)
Module.send(:include, Delayed::MessageSending::ClassMethods)

0 comments on commit 79cce65

Please sign in to comment.