Module: Mongoid::RadMiscellaneous
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/kit/mongoid/rad_miscellaneous.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#to_rson(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kit/mongoid/rad_miscellaneous.rb', line 6 def to_rson = {} with_errors = if .include?('errors') .delete 'errors' elsif .include?(:errors) .delete :errors else true end # standard MongoMaper as_json conversion hash = as_json() # MongoMaper fix hash['id'] = hash.delete('_id').to_s if hash.include? '_id' # adding errors if with_errors errors = {} errors.each do |name, list| errors[name.to_s] = list end hash['errors'] = errors unless errors.empty? end hash end |