Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
[dm-serializer] Should not assume association Proxy objects are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Kubb committed Dec 28, 2008
1 parent 827bd86 commit 0615854
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/dm-serializer/to_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ def to_json(*args)
end
end

# the json gem adds Object#to_json, which breaks the DM proxies, since it
# happens *after* the proxy has been blank slated. This code removes the added
# method, so it is delegated correctly to the Collection
[
Associations::OneToMany::Proxy,
(Associations::ManyToOne::Proxy if defined?(Associations::ManyToOne::Proxy)),
Associations::ManyToMany::Proxy
].each do |proxy|
[:to_json].each do |method|
proxy.send(:undef_method, :to_json) rescue nil
module Associations
# the json gem adds Object#to_json, which breaks the DM proxies, since it
# happens *after* the proxy has been blank slated. This code removes the added
# method, so it is delegated correctly to the Collection
[
(OneToMany::Proxy if defined?(OneToMany::Proxy)),
(ManyToOne::Proxy if defined?(ManyToOne::Proxy)),
(ManyToMany::Proxy if defined?(ManyToMany::Proxy)),
].each do |proxy|
[:to_json].each do |method|
proxy.send(:undef_method, :to_json) rescue nil
end
end
end

Expand Down

0 comments on commit 0615854

Please sign in to comment.