test for json adapter

This commit is contained in:
Tema Bolshakov and Dmitry Myaskovskiy
2014-08-29 19:40:01 +04:00
committed by Tema Bolshakov
parent 7293072670
commit ff37b6260d
5 changed files with 80 additions and 16 deletions

View File

@@ -3,9 +3,16 @@ module ActiveModel
class Adapter
class Json < Adapter
def serializable_hash(options = {})
serializer.attributes.each_with_object({}) do |(attr, value), h|
h[attr] = value
@hash = serializer.attributes
serializer.associations.each do |name, association|
if association.respond_to?(:each)
@hash[name] = association.map(&:attributes)
else
@hash[name] = association.attributes
end
end
@hash
end
end
end