Make valid_options a class method
This commit is contained in:
parent
0ee7331c35
commit
b83f3645c0
@ -60,12 +60,12 @@ def macro
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def valid_options
|
||||
def self.valid_options(options)
|
||||
VALID_OPTIONS + Association.extensions.flat_map(&:valid_options)
|
||||
end
|
||||
|
||||
def validate_options
|
||||
options.assert_valid_keys(valid_options)
|
||||
options.assert_valid_keys(self.class.valid_options(options))
|
||||
end
|
||||
|
||||
def self.define_extensions(model, name)
|
||||
|
@ -4,7 +4,7 @@ def macro
|
||||
:belongs_to
|
||||
end
|
||||
|
||||
def valid_options
|
||||
def self.valid_options(options)
|
||||
super + [:foreign_type, :polymorphic, :touch]
|
||||
end
|
||||
|
||||
|
@ -7,7 +7,7 @@ class CollectionAssociation < Association #:nodoc:
|
||||
|
||||
CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove]
|
||||
|
||||
def valid_options
|
||||
def self.valid_options(options)
|
||||
super + [:table_name, :before_add,
|
||||
:after_add, :before_remove, :after_remove, :extend]
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ def macro
|
||||
:has_many
|
||||
end
|
||||
|
||||
def valid_options
|
||||
def self.valid_options(options)
|
||||
super + [:primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache]
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ def macro
|
||||
:has_one
|
||||
end
|
||||
|
||||
def valid_options
|
||||
def self.valid_options(options)
|
||||
valid = super + [:order, :as]
|
||||
valid += [:through, :source, :source_type] if options[:through]
|
||||
valid
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module ActiveRecord::Associations::Builder
|
||||
class SingularAssociation < Association #:nodoc:
|
||||
def valid_options
|
||||
def self.valid_options(options)
|
||||
super + [:remote, :dependent, :counter_cache, :primary_key, :inverse_of]
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user