Skip to content
This repository
Browse code

Revert "Properly cache value when it is "false""

This reverts commit 551f313.

Reason: see
#2010 (comment)
  • Loading branch information...
commit e52dc331d16dd7a3b13383e21fba5cef5b228b9c 1 parent b015d92
Jon Leighton authored
4  activesupport/lib/active_support/cache.rb
@@ -555,7 +555,7 @@ def initialize(value, options = {})
555 555
         @expires_in = options[:expires_in]
556 556
         @expires_in = @expires_in.to_f if @expires_in
557 557
         @created_at = Time.now.to_f
558  
-        if defined?(value)
  558
+        if value
559 559
           if should_compress?(value, options)
560 560
             @value = Zlib::Deflate.deflate(Marshal.dump(value))
561 561
             @compressed = true
@@ -574,7 +574,7 @@ def raw_value
574 574
 
575 575
       # Get the value stored in the cache.
576 576
       def value
577  
-        if defined?(@value)
  577
+        if @value
578 578
           val = compressed? ? Marshal.load(Zlib::Inflate.inflate(@value)) : @value
579 579
           unless val.frozen?
580 580
             val.freeze rescue nil
5  activesupport/test/caching_test.rb
@@ -188,11 +188,6 @@ def test_should_read_and_write_nil
188 188
     assert_equal nil, @cache.read('foo')
189 189
   end
190 190
 
191  
-  def test_should_read_and_write_false
192  
-    assert_equal true, @cache.write('foo', false)
193  
-    assert_equal false, @cache.read('foo')
194  
-  end
195  
-
196 191
   def test_read_multi
197 192
     @cache.write('foo', 'bar')
198 193
     @cache.write('fu', 'baz')

0 notes on commit e52dc33

Please sign in to comment.
Something went wrong with that request. Please try again.