lib/dm-serializer/to_json.rb in dm-serializer-0.10.2 vs lib/dm-serializer/to_json.rb in dm-serializer-1.0.0.rc1
- old
+ new
@@ -40,10 +40,19 @@
result.to_json
else
result
end
end
+
+ module ValidationErrors
+ module ToJson
+ def to_json(*args)
+ errors.to_hash.to_json
+ end
+ end
+ end
+
end
module Associations
# the json gem adds Object#to_json, which breaks the DM proxies, since it
@@ -76,17 +85,16 @@
collection
end
end
end
- if Serialize::Support.dm_validations_loaded?
+ if Serialize.dm_validations_loaded?
- module Validate
+ module Validations
class ValidationErrors
- def to_json(*args)
- errors.to_hash.to_json
- end
+ include DataMapper::Serialize::ValidationErrors::ToJson
end
end
end
+
end