Skip to content

Commit f355477

Browse files
committed
cache entry: options[:compressed] is a regular flag, no need for !!
1 parent 91678a5 commit f355477

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

activesupport/lib/active_support/cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def create(raw_value, created_at, options = {})
542542
entry = new(nil)
543543
entry.instance_variable_set(:@value, raw_value)
544544
entry.instance_variable_set(:@created_at, created_at.to_f)
545-
entry.instance_variable_set(:@compressed, !!options[:compressed])
545+
entry.instance_variable_set(:@compressed, options[:compressed])
546546
entry.instance_variable_set(:@expires_in, options[:expires_in])
547547
entry
548548
end

activesupport/test/caching_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def test_create_raw_entry
723723
entry = ActiveSupport::Cache::Entry.create("raw", time, :compress => false, :expires_in => 300)
724724
assert_equal "raw", entry.raw_value
725725
assert_equal time.to_f, entry.created_at
726-
assert_equal false, entry.compressed?
726+
assert !entry.compressed?
727727
assert_equal 300, entry.expires_in
728728
end
729729

@@ -740,14 +740,14 @@ def test_expired
740740
def test_compress_values
741741
entry = ActiveSupport::Cache::Entry.new("value", :compress => true, :compress_threshold => 1)
742742
assert_equal "value", entry.value
743-
assert_equal true, entry.compressed?
743+
assert entry.compressed?
744744
assert_equal "value", Marshal.load(Zlib::Inflate.inflate(entry.raw_value))
745745
end
746746

747747
def test_non_compress_values
748748
entry = ActiveSupport::Cache::Entry.new("value")
749749
assert_equal "value", entry.value
750750
assert_equal "value", Marshal.load(entry.raw_value)
751-
assert_equal false, entry.compressed?
751+
assert !entry.compressed?
752752
end
753753
end

0 commit comments

Comments
 (0)