Sha256: 68539155101c895de50304899f0213aeeadec3b69a0c2e2279fd6df0dea3476e
Contents?: true
Size: 559 Bytes
Versions: 10
Compression:
Stored size: 559 Bytes
Contents
module MongoMapper module Associations class BelongsToProxy < Proxy def replace(v) ref_id = "#{@association.name}_id" if v v.save if v.new? @owner.__send__(:write_attribute, ref_id, v.id) else @owner.__send__(:write_attribute, ref_id, nil) end reload_target end protected def find_target ref = @owner.__send__(:read_attribute, "#{@association.name}_id") if ref @association.klass.find(ref) end end end end end
Version data entries
10 entries across 10 versions & 4 rubygems