diff options
author | John Maxwell <johnmaxwell@gmail.com> | 2009-07-22 20:47:15 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-07-22 20:47:15 -0500 |
commit | c39151a84768397d3bb025c6e8f877eac59ebbf9 (patch) | |
tree | a4e34e773ff2629abfab91925ed6cd3a2685408e /activemodel/lib/active_model/serializers | |
parent | 9d7aae710384fb5f04129c35b86c5ea5fb9d83a9 (diff) | |
download | rails-c39151a84768397d3bb025c6e8f877eac59ebbf9.tar.gz rails-c39151a84768397d3bb025c6e8f877eac59ebbf9.tar.bz2 rails-c39151a84768397d3bb025c6e8f877eac59ebbf9.zip |
Patch to ActiveModel's (and ActiveRecord, by association) XML serialization: If two parameters are present in Procs supplied to to_xml's :procs option, the model being serialized will be passed as the second argument [#2373 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activemodel/lib/active_model/serializers')
-rw-r--r-- | activemodel/lib/active_model/serializers/xml.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb index 76a0e54a56..8137300479 100644 --- a/activemodel/lib/active_model/serializers/xml.rb +++ b/activemodel/lib/active_model/serializers/xml.rb @@ -152,7 +152,11 @@ module ActiveModel def add_procs if procs = options.delete(:procs) [ *procs ].each do |proc| - proc.call(options) + if proc.arity > 1 + proc.call(options, @serializable) + else + proc.call(options) + end end end end |