diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-07 14:55:14 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-07 14:55:14 -0500 |
commit | a8057669ff6ba11e228fc73eef7390b826d0de25 (patch) | |
tree | fab205b4b3900d9c9a3ef0f169491ae94d327317 /activesupport/lib/active_support | |
parent | 105093f90728f81268367bd52581fccfa165f170 (diff) | |
download | rails-a8057669ff6ba11e228fc73eef7390b826d0de25.tar.gz rails-a8057669ff6ba11e228fc73eef7390b826d0de25.tar.bz2 rails-a8057669ff6ba11e228fc73eef7390b826d0de25.zip |
Fixed memoize with punctuation and freezing memoized methods with arguments
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/memoizable.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/memoizable.rb b/activesupport/lib/active_support/memoizable.rb index 7e2e28712c..e6049d9496 100644 --- a/activesupport/lib/active_support/memoizable.rb +++ b/activesupport/lib/active_support/memoizable.rb @@ -10,9 +10,16 @@ module ActiveSupport end def freeze_with_memoizable - methods.each do |method| - __send__($1) if method.to_s =~ /^_unmemoized_(.*)/ - end unless frozen? + unless frozen? + methods.each do |method| + if method.to_s =~ /^_unmemoized_(.*)/ + begin + __send__($1) + rescue ArgumentError + end + end + end + end freeze_without_memoizable end @@ -21,7 +28,7 @@ module ActiveSupport def memoize(*symbols) symbols.each do |symbol| original_method = "_unmemoized_#{symbol}" - memoized_ivar = "@_memoized_#{symbol}" + memoized_ivar = "@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}" class_eval <<-EOS, __FILE__, __LINE__ include Freezable |