Sha256: 4d336d7d5ba62e5363f0026142beb22fa358801244bab3e944894e0a76a2abb2

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

require "blobby/key_constraint"

module Blobby

  # A BLOB store that is always successful.
  #
  class FakeSuccessStore

    def available?
      true
    end

    def [](key)
      KeyConstraint.must_allow!(key)
      StoredObject.new
    end

    class StoredObject

      def exists?
        true
      end

      def read
        image_path = Pathname(File.dirname(__FILE__)) + "placeholder.png"
        image_path.open("rb") do |io|
          if block_given?
            while (chunk = io.read(512))
              yield chunk
            end
            nil
          else
            io.read
          end
        end
      rescue Errno::ENOENT
        nil
      end

      def write(_content)
        nil
      end

      def delete
        true
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blobby-1.1.0 lib/blobby/fake_success_store.rb