class Google::Cloud::Storage::Bucket::Updater

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

Attributes

updates[R]

Public Class Methods

new(gapi) click to toggle source

Create an Updater object.

Calls superclass method Google::Cloud::Storage::Bucket::new
# File lib/google/cloud/storage/bucket.rb, line 2863
def initialize gapi
  super()
  @updates = []
  @gapi = gapi
  @labels = @gapi.labels.to_h.dup
  @cors_builder = nil
  @lifecycle_builder = nil
end

Public Instance Methods

check_for_changed_labels!() click to toggle source

@private Make sure any labels changes are saved

# File lib/google/cloud/storage/bucket.rb, line 2894
def check_for_changed_labels!
  return if @labels == @gapi.labels.to_h
  @gapi.labels = @labels
  patch_gapi! :labels
end
check_for_mutable_cors!() click to toggle source

@private Make sure any cors changes are saved

# File lib/google/cloud/storage/bucket.rb, line 2909
def check_for_mutable_cors!
  return if @cors_builder.nil?
  return unless @cors_builder.changed?
  @gapi.cors_configurations = @cors_builder.to_gapi
  patch_gapi! :cors_configurations
end
check_for_mutable_lifecycle!() click to toggle source

@private Make sure any lifecycle changes are saved

# File lib/google/cloud/storage/bucket.rb, line 2925
def check_for_mutable_lifecycle!
  return if @lifecycle_builder.nil?
  return unless @lifecycle_builder.changed?
  @gapi.lifecycle = @lifecycle_builder.to_gapi
  patch_gapi! :lifecycle
end
cors() { |cors_builder| ... } click to toggle source
# File lib/google/cloud/storage/bucket.rb, line 2900
def cors
  # Same as Bucket#cors, but not frozen
  @cors_builder ||= Bucket::Cors.from_gapi @gapi.cors_configurations
  yield @cors_builder if block_given?
  @cors_builder
end
labels() click to toggle source

A hash of user-provided labels. Changes are allowed.

@return [Hash(String => String)]

# File lib/google/cloud/storage/bucket.rb, line 2877
def labels
  @labels
end
labels=(labels) click to toggle source

Updates the hash of user-provided labels.

@param [Hash(String => String)] labels The user-provided labels.

# File lib/google/cloud/storage/bucket.rb, line 2886
def labels= labels
  @labels = labels
  @gapi.labels = @labels
  patch_gapi! :labels
end
lifecycle() { |lifecycle_builder| ... } click to toggle source
# File lib/google/cloud/storage/bucket.rb, line 2916
def lifecycle
  # Same as Bucket#lifecycle, but not frozen
  @lifecycle_builder ||= Bucket::Lifecycle.from_gapi @gapi.lifecycle
  yield @lifecycle_builder if block_given?
  @lifecycle_builder
end

Protected Instance Methods

patch_gapi!(attribute) click to toggle source

Queue up all the updates instead of making them.

# File lib/google/cloud/storage/bucket.rb, line 2936
def patch_gapi! attribute
  @updates << attribute
  @updates.uniq!
end