class Google::Cloud::Storage::File::Updater

Yielded to a block to accumulate changes for a patch request.

Constants

COPY_ATTRS

@private Whitelist of Google::Apis::StorageV1::Object attributes to be copied when File#copy or File#rewrite is called with `force_copy_metadata: true`.

Attributes

gapi[R]

@private

updates[R]

@private

Public Class Methods

new(gapi) click to toggle source

@private Create an Updater object.

Calls superclass method Google::Cloud::Storage::File::new
# File lib/google/cloud/storage/file.rb, line 2164
def initialize gapi
  super()
  @updates = []
  @gapi = gapi
  @metadata ||= @gapi.metadata.to_h.dup
end

Public Instance Methods

check_for_changed_metadata!() click to toggle source

@private Make sure any metadata changes are saved

# File lib/google/cloud/storage/file.rb, line 2198
def check_for_changed_metadata!
  return if @metadata == @gapi.metadata.to_h
  @gapi.metadata = @metadata
  update_gapi! :metadata
end
metadata() click to toggle source

A hash of custom, user-provided web-safe keys and arbitrary string values that will returned with requests for the file as “x-goog-meta-” response headers.

@return [Hash(String => String)]

# File lib/google/cloud/storage/file.rb, line 2178
def metadata
  @metadata
end
metadata=(metadata) click to toggle source

Updates the hash of custom, user-provided web-safe keys and arbitrary string values that will returned with requests for the file as “x-goog-meta-” response headers.

@param [Hash(String => String)] metadata The user-provided metadata,

in key/value pairs.
# File lib/google/cloud/storage/file.rb, line 2190
def metadata= metadata
  @metadata = metadata
  @gapi.metadata = @metadata
  update_gapi! :metadata
end

Protected Instance Methods

update_gapi!(attribute) click to toggle source

Queue up all the updates instead of making them.

# File lib/google/cloud/storage/file.rb, line 2208
def update_gapi! attribute
  @updates << attribute
  @updates.uniq!
end