From 646bfe1a5e7b30863e5ab8a5927246be3a69ed3b Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 20 Aug 2013 19:27:17 -0700 Subject: Avoid compiling regexs in AR::Base.respond_to? Caches the patterns of ActiveRecord::DynamicMatchers in a class instance variable. --- activerecord/lib/active_record/dynamic_matchers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/dynamic_matchers.rb b/activerecord/lib/active_record/dynamic_matchers.rb index 3bac31c6aa..e650ebcf64 100644 --- a/activerecord/lib/active_record/dynamic_matchers.rb +++ b/activerecord/lib/active_record/dynamic_matchers.rb @@ -35,7 +35,7 @@ module ActiveRecord end def pattern - /^#{prefix}_([_a-zA-Z]\w*)#{suffix}$/ + @pattern ||= /\A#{prefix}_([_a-zA-Z]\w*)#{suffix}\Z/ end def prefix -- cgit v1.2.3