8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/rad/mongo_mapper/rad_micelaneous.rb', line 8
def to_rson options = {}
with_errors = if options.include?('errors')
options.delete 'errors'
elsif options.include?(:errors)
options.delete :errors
else
true
end
hash = as_json(options)
hash['id'] = hash.delete :id if hash.include? :id
if with_errors
errors = {}
errors.each do |name, list|
errors[name.to_s] = list
end
hash['errors'] = errors unless errors.empty?
end
hash
end
|