aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-02 15:05:06 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-02 15:28:49 -0700
commit22f05afb2d79f8088e49710d4e9e3ba1883bf11e (patch)
tree13f43cb5d8a38299c77afbe4ecb5a6da6ebb1c45 /activerecord
parenta88a5d73704307f9fcd1187ddeba0bbfd7b5968c (diff)
downloadrails-22f05afb2d79f8088e49710d4e9e3ba1883bf11e.tar.gz
rails-22f05afb2d79f8088e49710d4e9e3ba1883bf11e.tar.bz2
rails-22f05afb2d79f8088e49710d4e9e3ba1883bf11e.zip
valid_options doesn't depend on the instance, so push it to the class
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/builder/association.rb6
-rw-r--r--activerecord/lib/active_record/associations/builder/belongs_to.rb2
-rw-r--r--activerecord/lib/active_record/associations/builder/has_many.rb2
-rw-r--r--activerecord/lib/active_record/associations/builder/has_one.rb6
4 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb
index 2edea96170..e6da251550 100644
--- a/activerecord/lib/active_record/associations/builder/association.rb
+++ b/activerecord/lib/active_record/associations/builder/association.rb
@@ -104,15 +104,15 @@ module ActiveRecord::Associations::Builder
CODE
end
- def valid_dependent_options
+ def self.valid_dependent_options
raise NotImplementedError
end
private
def add_before_destroy_callbacks(model, reflection)
- unless valid_dependent_options.include? reflection.options[:dependent]
- raise ArgumentError, "The :dependent option must be one of #{valid_dependent_options}, but is :#{reflection.options[:dependent]}"
+ unless self.class.valid_dependent_options.include? reflection.options[:dependent]
+ raise ArgumentError, "The :dependent option must be one of #{self.class.valid_dependent_options}, but is :#{reflection.options[:dependent]}"
end
name = reflection.name
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb
index 2755eb7c6d..1d9492a3bd 100644
--- a/activerecord/lib/active_record/associations/builder/belongs_to.rb
+++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -8,7 +8,7 @@ module ActiveRecord::Associations::Builder
super + [:foreign_type, :polymorphic, :touch]
end
- def valid_dependent_options
+ def self.valid_dependent_options
[:destroy, :delete]
end
diff --git a/activerecord/lib/active_record/associations/builder/has_many.rb b/activerecord/lib/active_record/associations/builder/has_many.rb
index a60cb4769a..7909b93622 100644
--- a/activerecord/lib/active_record/associations/builder/has_many.rb
+++ b/activerecord/lib/active_record/associations/builder/has_many.rb
@@ -8,7 +8,7 @@ module ActiveRecord::Associations::Builder
super + [:primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache]
end
- def valid_dependent_options
+ def self.valid_dependent_options
[:destroy, :delete_all, :nullify, :restrict_with_error, :restrict_with_exception]
end
end
diff --git a/activerecord/lib/active_record/associations/builder/has_one.rb b/activerecord/lib/active_record/associations/builder/has_one.rb
index accd29e5ef..a2509b5bae 100644
--- a/activerecord/lib/active_record/associations/builder/has_one.rb
+++ b/activerecord/lib/active_record/associations/builder/has_one.rb
@@ -10,14 +10,14 @@ module ActiveRecord::Associations::Builder
valid
end
- def valid_dependent_options
+ def self.valid_dependent_options
[:destroy, :delete, :nullify, :restrict_with_error, :restrict_with_exception]
end
private
- def add_before_destroy_callbacks(model, name)
- super unless options[:through]
+ def add_before_destroy_callbacks(model, reflection)
+ super unless reflection.options[:through]
end
end
end