diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-13 21:30:46 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-13 21:30:46 -0500 |
commit | 8cb14ee1203c9ed380c4b192e8730757a52d43cb (patch) | |
tree | d69be4eac1b7ecd0457de284549e28d729f40914 /activesupport/lib/active_support | |
parent | b8b30985d525fd15b6c16d29fc115e83e3ee5037 (diff) | |
download | rails-8cb14ee1203c9ed380c4b192e8730757a52d43cb.tar.gz rails-8cb14ee1203c9ed380c4b192e8730757a52d43cb.tar.bz2 rails-8cb14ee1203c9ed380c4b192e8730757a52d43cb.zip |
Ensure results returned by a memoized method are immutable
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/memoizable.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/memoizable.rb b/activesupport/lib/active_support/memoizable.rb index 5aa73bce52..6506238ac0 100644 --- a/activesupport/lib/active_support/memoizable.rb +++ b/activesupport/lib/active_support/memoizable.rb @@ -51,7 +51,7 @@ module ActiveSupport if instance_method(:#{symbol}).arity == 0 def #{symbol}(reload = false) if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? - #{memoized_ivar} = [#{original_method}] + #{memoized_ivar} = [#{original_method}.freeze] end #{memoized_ivar}[0] end @@ -64,7 +64,7 @@ module ActiveSupport if !reload && #{memoized_ivar}.has_key?(args) #{memoized_ivar}[args] elsif #{memoized_ivar} - #{memoized_ivar}[args] = #{original_method}(*args) + #{memoized_ivar}[args] = #{original_method}(*args).freeze end else #{original_method}(*args) |