Skip to content

Commit

Permalink
Fix ActiveRecord::Base#encode_with for Rails 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
albus522 committed Apr 1, 2013
1 parent 7d3704b commit dcf414b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/delayed/psych_ext.rb
@@ -1,11 +1,18 @@
if defined?(ActiveRecord) if defined?(ActiveRecord)
ActiveRecord::Base.class_eval do ActiveRecord::Base.class_eval do
def encode_with_override(coder) if instance_methods.include?(:encode_with)
encode_with_without_override(coder) def encode_with_override(coder)
coder.tag = "!ruby/ActiveRecord:#{self.class.name}" encode_with_without_override(coder)
coder.tag = "!ruby/ActiveRecord:#{self.class.name}"
end
alias_method :encode_with_without_override, :encode_with
alias_method :encode_with, :encode_with_override
else
def encode_with(coder)
coder["attributes"] = attributes
coder.tag = "!ruby/ActiveRecord:#{self.class.name}"
end
end end
alias_method :encode_with_without_override, :encode_with
alias_method :encode_with, :encode_with_override
end end
end end


Expand Down

0 comments on commit dcf414b

Please sign in to comment.