diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-13 01:10:37 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-13 12:00:15 -0700 |
commit | e8550ee0329586b32de425e905c7af7e65bc78a8 (patch) | |
tree | 0cdfe0f9f0d3fb010280ff0453fc553ab6ff2d92 /activerecord/lib/active_record/serialization.rb | |
parent | fa5da8ad54d68ea0484825845eb6f6a8e8bca361 (diff) | |
download | rails-e8550ee0329586b32de425e905c7af7e65bc78a8.tar.gz rails-e8550ee0329586b32de425e905c7af7e65bc78a8.tar.bz2 rails-e8550ee0329586b32de425e905c7af7e65bc78a8.zip |
Cherry-pick core extensions
Diffstat (limited to 'activerecord/lib/active_record/serialization.rb')
-rw-r--r-- | activerecord/lib/active_record/serialization.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/serialization.rb b/activerecord/lib/active_record/serialization.rb index 78f66c3a73..7959f2b510 100644 --- a/activerecord/lib/active_record/serialization.rb +++ b/activerecord/lib/active_record/serialization.rb @@ -1,5 +1,3 @@ -require 'active_support/json' - module ActiveRecord #:nodoc: module Serialization class Serializer #:nodoc: @@ -73,16 +71,19 @@ module ActiveRecord #:nodoc: end def serializable_record - returning(serializable_record = {}) do - serializable_names.each { |name| serializable_record[name] = @record.send(name) } - add_includes do |association, records, opts| + record = {} + serializable_names.each { |name| record[name] = @record.send(name) } + + add_includes do |association, records, opts| + record[association] = if records.is_a?(Enumerable) - serializable_record[association] = records.collect { |r| self.class.new(r, opts).serializable_record } + records.collect { |r| self.class.new(r, opts).serializable_record } else - serializable_record[association] = self.class.new(records, opts).serializable_record + self.class.new(records, opts).serializable_record end - end end + + record end def serialize |