Sha256: 804a3b7bbb93e1f73c861bcab3e19632bbe22365741a07af2757d8331de88d0a

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 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

2 entries across 2 versions & 1 rubygems

Version Path
blobby-1.0.1 lib/blobby/fake_success_store.rb
blobby-1.0.0 lib/blobby/fake_success_store.rb