Class: Gcloud::Storage::Bucket::Updater

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/storage/bucket.rb

Overview

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

Constant Summary collapse

ATTRS =
[:cors, :logging_bucket, :logging_prefix, :versioning,
:website_main, :website_404]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cors) ⇒ Updater

Create an Updater object.



793
794
795
796
797
# File 'lib/gcloud/storage/bucket.rb', line 793

def initialize cors
  @cors = cors ? Array(cors.dup) : []
  @cors = @cors.map { |x| x.to_hash if x.respond_to? :to_hash }
  @updates = {}
end

Instance Attribute Details

#updatesObject (readonly)

Returns the value of attribute updates.



790
791
792
# File 'lib/gcloud/storage/bucket.rb', line 790

def updates
  @updates
end

Instance Method Details

#corsObject

Return CORS for mutation. Also adds CORS to @updates so that it is included in the patch request.



811
812
813
814
815
816
817
818
819
# File 'lib/gcloud/storage/bucket.rb', line 811

def cors
  updates[:cors] ||= @cors
  if block_given?
    cors_builder = Bucket::Cors.new updates[:cors]
    yield cors_builder
    updates[:cors] = cors_builder if cors_builder.changed?
  end
  updates[:cors]
end