This method is deprecated or moved on the latest stable version.
The last existing version (v3.0.9) is shown here.
configure_dependency_for_has_one(reflection)
private
Creates before_destroy callback methods that nullify, delete or destroy has_one
associated objects, according to the defined :dependent rule. If the
association is marked as :dependent => :restrict, create a callback that
prevents deleting entirely.
# File activerecord/lib/active_record/associations.rb, line 1653
def configure_dependency_for_has_one(reflection)
if reflection.options.include?(:dependent)
name = reflection.options[:dependent]
method_name = :"has_one_dependent_#{name}_for_#{reflection.name}"
case name
when :destroy, :delete
class_eval def #{method_name} association = #{reflection.name} association.#{name} if association end, __FILE__, __LINE__ + 1
when :nullify
class_eval def #{method_name} association = #{reflection.name} association.update_attribute(#{reflection.primary_key_name.inspect}, nil) if association end, __FILE__, __LINE__ + 1
when :restrict
method_name = "has_one_dependent_restrict_for_#{reflection.name}".to_sym
define_method(method_name) do
unless send(reflection.name).nil?
raise DeleteRestrictionError.new(reflection)
end
end
before_destroy method_name
else
raise ArgumentError, "The :dependent option expects either :destroy, :delete, :nullify or :restrict (#{reflection.options[:dependent].inspect})"
end
before_destroy method_name
end
end