lib/blobby/in_memory_store.rb in blobby-1.1.0 vs lib/blobby/in_memory_store.rb in blobby-1.1.1

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require "blobby/key_constraint" module Blobby # A BLOB store backed by a Hash. @@ -21,10 +23,11 @@ def [](key) KeyConstraint.must_allow!(key) StoredObject.new(@hash, key) end + # Represents an object in the store. class StoredObject def initialize(hash, key) @hash = hash @key = key @@ -45,14 +48,14 @@ content end end def write(content) - if content.respond_to?(:read) - content = content.read - else - content = content.to_str.dup - end + content = if content.respond_to?(:read) + content.read + else + content.to_str.dup + end content = content.force_encoding("BINARY") if content.respond_to?(:force_encoding) @hash[key] = content nil end