Skip to content

Refactor define_restrict_dependency_method using reflection #4835

Merged
merged 1 commit into from May 19, 2012

3 participants

@pacoguzman

We need to know if the reflection macro is equal to has_one in two lines so I'd cached in a variable

@isaacsanders

Is this still an issue?

@pacoguzman

@isaacsanders only a little refactor, IMHO reflects better what happening there

@isaacsanders isaacsanders commented on the diff May 4, 2012
...lib/active_record/associations/builder/association.rb
@@ -69,12 +69,12 @@ def dependent_restrict_deprecation_warning
def define_restrict_dependency_method
name = self.name
mixin.redefine_method(dependency_method_name) do
- # has_many or has_one associations
- if send(name).respond_to?(:exists?) ? send(name).exists? : !send(name).nil?
@isaacsanders
isaacsanders added a note May 4, 2012

Is this the same as has_one_macro in the code below?

@pacoguzman
pacoguzman added a note May 4, 2012

In this commit - 336ff8a

the code is splitted in two files has_one and has_many with that condition so IMHO is the same, in some later commits we merge that code in an unique place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@carlosantoniodasilva carlosantoniodasilva merged commit 8405aad into rails:master May 19, 2012
@carlosantoniodasilva
Ruby on Rails member

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.