lib/dm-serializer/to_json.rb in dm-serializer-1.1.0 vs lib/dm-serializer/to_json.rb in dm-serializer-1.2.0.rc1
- old
+ new
@@ -1,8 +1,8 @@
require 'dm-serializer/common'
-require 'json'
+require 'multi_json'
module DataMapper
module Serializer
#
# Converts the resource into a hash of properties.
@@ -58,20 +58,20 @@
result = as_json(options)
# default to making JSON
if options.fetch(:to_json, true)
- result.to_json
+ MultiJson.encode(result)
else
result
end
end
module ValidationErrors
module ToJson
def to_json(*args)
- DataMapper::Ext::Array.to_hash(errors).to_json
+ MultiJson.encode(Hash[ errors ])
end
end
end
end
@@ -91,16 +91,13 @@
collection
end
end
end
- if Serializer.dm_validations_loaded?
-
+ if const_defined?(:Validations)
module Validations
class ValidationErrors
include DataMapper::Serializer::ValidationErrors::ToJson
end
end
-
end
-
end