From c8ad4cd525a9f977014bc519c8c394a059000ff5 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Tue, 21 Sep 2010 18:26:30 +1000 Subject: [PATCH] use inheritable hash again as class_attribute doesn't clone hash for subclass --- lib/validates_timeliness/attribute_methods.rb | 1 + lib/validates_timeliness/helper_methods.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/validates_timeliness/attribute_methods.rb b/lib/validates_timeliness/attribute_methods.rb index 1e67b03..c4fa7cd 100644 --- a/lib/validates_timeliness/attribute_methods.rb +++ b/lib/validates_timeliness/attribute_methods.rb @@ -5,6 +5,7 @@ module ValidatesTimeliness module ClassMethods def define_timeliness_methods(before_type_cast=false) + return if timeliness_validated_attributes.blank? timeliness_validated_attributes.each do |attr_name, type| define_timeliness_write_method(attr_name, type, timeliness_attribute_timezone_aware?(attr_name)) define_timeliness_before_type_cast_method(attr_name) if before_type_cast diff --git a/lib/validates_timeliness/helper_methods.rb b/lib/validates_timeliness/helper_methods.rb index 9b1fb26..d5d5bb1 100644 --- a/lib/validates_timeliness/helper_methods.rb +++ b/lib/validates_timeliness/helper_methods.rb @@ -5,7 +5,7 @@ module ValidatesTimeliness included do include ValidationMethods extend ValidationMethods - class_attribute :timeliness_validated_attributes + class_inheritable_hash :timeliness_validated_attributes self.timeliness_validated_attributes = {} end @@ -30,7 +30,7 @@ module ValidatesTimeliness validated[attr_name] = type validated } - self.timeliness_validated_attributes.update(attributes) + self.timeliness_validated_attributes = attributes validates_with Validator, options end