From 2702ec3266c8c6732ce3d79ec16920305c9c68dd Mon Sep 17 00:00:00 2001 From: Chris Griego Date: Tue, 10 Jan 2012 17:16:05 -0600 Subject: [PATCH] The ActiveRecord extension now returns the original return value for .define_attribute_methods This helps other extensions, like PermalinkFu, which depend on the return value --- lib/validates_timeliness/orm/active_record.rb | 7 ++++--- spec/validates_timeliness/orm/active_record_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/validates_timeliness/orm/active_record.rb b/lib/validates_timeliness/orm/active_record.rb index 749a3ca..00f2bbb 100644 --- a/lib/validates_timeliness/orm/active_record.rb +++ b/lib/validates_timeliness/orm/active_record.rb @@ -18,9 +18,10 @@ module ValidatesTimeliness module ClassMethods def define_attribute_methods - super - use_before_type_cast = ValidatesTimeliness::ORM::ActiveRecord.use_plugin_cache? - define_timeliness_methods use_before_type_cast + super.tap do |attribute_methods_generated| + use_before_type_cast = ValidatesTimeliness::ORM::ActiveRecord.use_plugin_cache? + define_timeliness_methods use_before_type_cast + end end def define_timeliness_methods(before_type_cast=false) diff --git a/spec/validates_timeliness/orm/active_record_spec.rb b/spec/validates_timeliness/orm/active_record_spec.rb index 8b72cc5..1ee257c 100644 --- a/spec/validates_timeliness/orm/active_record_spec.rb +++ b/spec/validates_timeliness/orm/active_record_spec.rb @@ -119,4 +119,10 @@ describe ValidatesTimeliness, 'ActiveRecord' do end end + + context "define_attribute_methods" do + it "returns a falsy value if the attribute methods have already been generated" do + Employee.define_attribute_methods.should be_false + end + end end