class MongoModel::Associations::BelongsTo::Association
Public Instance Methods
find_target()
click to toggle source
# File lib/mongomodel/concerns/associations/belongs_to.rb, line 68 def find_target target_class.find(target_id) if target_id && target_class end
replace(obj)
click to toggle source
Calls superclass method
MongoModel::Associations::Base::Association#replace
# File lib/mongomodel/concerns/associations/belongs_to.rb, line 59 def replace(obj) ensure_class(obj) if obj && !polymorphic? instance[foreign_key] = obj ? obj.id : nil instance[type_key] = obj ? obj.class : nil if polymorphic? super end
target_class()
click to toggle source
# File lib/mongomodel/concerns/associations/belongs_to.rb, line 51 def target_class if polymorphic? instance[type_key].constantize rescue nil else klass end end
target_id()
click to toggle source
# File lib/mongomodel/concerns/associations/belongs_to.rb, line 47 def target_id instance[foreign_key] end
Protected Instance Methods
proxy_class()
click to toggle source
# File lib/mongomodel/concerns/associations/belongs_to.rb, line 73 def proxy_class Base::Proxy end