diff options
author | Damien Mathieu <42@dmathieu.com> | 2011-06-15 09:46:05 +0200 |
---|---|---|
committer | Damien Mathieu <42@dmathieu.com> | 2011-06-15 09:46:53 +0200 |
commit | 9791e3e25221818f283e5e734772462b0d2d7d5d (patch) | |
tree | 4a105c0aa8622a8d3e56e10b86bc13ebb2592e8a /activesupport/lib | |
parent | 10cfd146495964b01e6e195598bdb0d91c6011ad (diff) | |
download | rails-9791e3e25221818f283e5e734772462b0d2d7d5d.tar.gz rails-9791e3e25221818f283e5e734772462b0d2d7d5d.tar.bz2 rails-9791e3e25221818f283e5e734772462b0d2d7d5d.zip |
allow boolean last argument in memoized methods - Closes #1704
If in the memoized method, the last argument is a boolean, it's considered as the reload method.
Don't consider it like that if that's a normal method argument.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/memoizable.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/memoizable.rb b/activesupport/lib/active_support/memoizable.rb index 0a7bcd5bb8..279f1cf71f 100644 --- a/activesupport/lib/active_support/memoizable.rb +++ b/activesupport/lib/active_support/memoizable.rb @@ -79,7 +79,11 @@ module ActiveSupport else # else def #{symbol}(*args) # def mime_type(*args) #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen? - reload = args.pop if args.last == true || args.last == :reload # reload = args.pop if args.last == true || args.last == :reload + args_length = method(:#{original_method}).arity # args_length = method(:_unmemoized_mime_type).arity + if args.length == args_length + 1 && # if args.length == args_length + 1 && + (args.last == true || args.last == :reload) # (args.last == true || args.last == :reload) + reload = args.pop # reload = args.pop + end # end # if defined?(#{memoized_ivar}) && #{memoized_ivar} # if defined?(@_memoized_mime_type) && @_memoized_mime_type if !reload && #{memoized_ivar}.has_key?(args) # if !reload && @_memoized_mime_type.has_key?(args) |