Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

valid_options doesn't depend on the instance, so push it to the class

  • Loading branch information...
commit 22f05afb2d79f8088e49710d4e9e3ba1883bf11e 1 parent a88a5d7
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/associations/builder/association.rb
@@ -104,15 +104,15 @@ def #{name}=(value)
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
View
2  activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -8,7 +8,7 @@ def valid_options
super + [:foreign_type, :polymorphic, :touch]
end
- def valid_dependent_options
+ def self.valid_dependent_options
[:destroy, :delete]
end
View
2  activerecord/lib/active_record/associations/builder/has_many.rb
@@ -8,7 +8,7 @@ def valid_options
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
View
6 activerecord/lib/active_record/associations/builder/has_one.rb
@@ -10,14 +10,14 @@ def valid_options
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

0 comments on commit 22f05af

Please sign in to comment.
Something went wrong with that request. Please try again.