From 30fb0e5192700c78275dfecb6b7b34e794db685d Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Tue, 10 Aug 2010 15:41:53 +1000 Subject: [PATCH] before_type_cast fix for ORMs not using it wont create --- lib/validates_timeliness/attribute_methods.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/validates_timeliness/attribute_methods.rb b/lib/validates_timeliness/attribute_methods.rb index fe9f0de..2ddc276 100644 --- a/lib/validates_timeliness/attribute_methods.rb +++ b/lib/validates_timeliness/attribute_methods.rb @@ -3,7 +3,9 @@ module ValidatesTimeliness extend ActiveSupport::Concern included do - attribute_method_suffix "_before_type_cast" + if attribute_method_matchers.any? {|m| m.suffix == "_before_type_cast" && m.prefix.blank? } + extend BeforeTypeCastMethods + end end module ClassMethods @@ -25,6 +27,10 @@ module ValidatesTimeliness end end + end + + module BeforeTypeCastMethods + def define_method_attribute_before_type_cast(attr_name) if timeliness_validated_attributes.include?(attr_name) method_body, line = <<-EOV, __LINE__ + 1 @@ -39,5 +45,6 @@ module ValidatesTimeliness end end + end end