Hook into undefine_attributes_methods to remove timeliness methods as well

This commit is contained in:
Adam Meehan
2012-02-01 20:38:05 +11:00
parent f8aeeca0a9
commit 5be45b00db
4 changed files with 38 additions and 3 deletions

View File

@@ -20,6 +20,11 @@ module ValidatesTimeliness
:datetime
end
def undefine_attribute_methods
super
undefine_timeliness_attribute_methods
end
protected
def define_timeliness_methods(before_type_cast=false)
@@ -65,6 +70,12 @@ module ValidatesTimeliness
def generated_timeliness_methods
@generated_timeliness_methods ||= Module.new.tap { |m| include(m) }
end
def undefine_timeliness_attribute_methods
generated_timeliness_methods.module_eval do
instance_methods.each { |m| undef_method(m) }
end
end
end
def _timeliness_raw_value_for(attr_name)