mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
Hook into undefine_attributes_methods to remove timeliness methods as well
This commit is contained in:
@@ -10,6 +10,16 @@ module ConfigHelper
|
||||
ValidatesTimeliness.send(:"#{preference_name}=", old_value)
|
||||
end
|
||||
|
||||
def reset_validation_setup_for(model_class)
|
||||
model_class.reset_callbacks(:validate)
|
||||
model_class._validators.clear
|
||||
model_class.timeliness_validated_attributes = [] if model_class.respond_to?(:timeliness_validated_attributes)
|
||||
model_class.undefine_attribute_methods
|
||||
# This is a hack to avoid a disabled super method error message after an undef
|
||||
model_class.instance_variable_set(:@generated_attribute_methods, nil)
|
||||
model_class.instance_variable_set(:@generated_timeliness_methods, nil)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def with_config(preference_name, temporary_value)
|
||||
original_config_value = ValidatesTimeliness.send(preference_name)
|
||||
|
||||
Reference in New Issue
Block a user