class ActiveForce::Association::BelongsToAssociation
Public Instance Methods
relationship_name()
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 4 def relationship_name options[:relationship_name] || default_relationship_name end
Private Instance Methods
default_foreign_key()
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 26 def default_foreign_key infer_foreign_key_from_model relation_model end
default_relationship_name()
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 18 def default_relationship_name if !parent.custom_table? && !relation_model.custom_table? relation_model.table_name else parent.mappings[foreign_key].gsub(/__c\z/, '__r') end end
define_assignment_method()
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 34 def define_assignment_method association = self method_name = relation_name parent.send :define_method, "#{method_name}=" do |other| send "#{association.foreign_key}=", other&.id association_cache[method_name] = other end end
foreign_key_value(owner)
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 30 def foreign_key_value(owner) owner&.public_send(foreign_key) end
loadable?(owner)
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 10 def loadable?(owner) foreign_key_value(owner).present? end
target(owner)
click to toggle source
# File lib/active_force/association/belongs_to_association.rb, line 14 def target(owner) relation_model.find(foreign_key_value(owner)) end