Sha256: 2df64df78fd8687a3cf19fc32e81db830e26001b5457742b53d3eb84aed9f416

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

require "stashify/file"

module Stashify
  class File
    module Google
      module Cloud
        class Storage < Stashify::File
          def initialize(bucket:, path:)
            @bucket = bucket
            super(path: path)
          end

          def contents
            @bucket.file(path).download.string
          end

          def write(contents)
            @bucket.create_file(
              StringIO.new(contents),
              path,
            )
          end

          def delete
            @bucket.file(path).delete
          end

          def exists?
            @bucket.file(path)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stashify-google-cloud-storage-3.1.0 lib/stashify/file/google/cloud/storage.rb