Module: Mongoid::SerializableId

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongoid/serializable_id.rb

Instance Method Summary collapse

Instance Method Details

#serializable_hash(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mongoid/serializable_id.rb', line 5

def serializable_hash(options={})
  attrs = super(options)
  attrs.each_pair do |k, v|
    if k.end_with?('_id')
      attrs[k] = v.to_s
    end

    if k.end_with?('_ids')
      attrs[k] = attrs[k].collect { |id| id.to_s }
    end
  end
  attrs
end