Sha256: 36a6bdbe935bc66ab7041009958f6990e1ff2d2f4a399554270b6d3a74d4a6db

Contents?: true

Size: 686 Bytes

Versions: 4

Compression:

Stored size: 686 Bytes

Contents

module AssetCloud

  class MemoryBucket < Bucket

    def initialize(*args)
      super
      @memory = {}
    end

    def ls(prefix=nil)
      results = []
      @memory.each do |k,v|
        results.push(cloud[k]) if prefix.nil? || k.starts_with?(prefix)
      end
      results
    end

    def read(key)
      raise AssetCloud::AssetNotFoundError, key unless @memory.has_key?(key)
      @memory[key]
    end

    def delete(key)
      @memory.delete(key)
    end

    def write(key, data)
      @memory[key] = data

      true
    end

    def stat(key)
      return Metadata.non_existing unless @memory.has_key?(key)

      Metadata.new(true, read(key).size)
    end

  end


end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asset_cloud-2.0.0 lib/asset_cloud/buckets/memory_bucket.rb
asset_cloud-1.1.1 lib/asset_cloud/buckets/memory_bucket.rb
asset_cloud-1.1.0 lib/asset_cloud/buckets/memory_bucket.rb
asset_cloud-1.0.2 lib/asset_cloud/buckets/memory_bucket.rb