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