lib/alba/serializer.rb in alba-0.3.0 vs lib/alba/serializer.rb in alba-0.4.0
- old
+ new
@@ -15,15 +15,18 @@
key = @_opts[:key]
@_resource = {key.to_sym => @_resource} if key
end
def serialize
- fallback = -> { @_resource.to_json }
+ fallback = lambda do
+ require 'json'
+ JSON.dump(@_resource)
+ end
case Alba.backend
when :oj
begin
require 'oj'
- -> { Oj.dump(@_resource) }
+ -> { Oj.dump(@_resource, mode: :strict) }
rescue LoadError
fallback
end
else
fallback