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.


786
787
788
789
790
# File 'lib/gcloud/storage/bucket.rb', line 786

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


783
784
785
# File 'lib/gcloud/storage/bucket.rb', line 783

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.


804
805
806
807
808
809
810
811
812
# File 'lib/gcloud/storage/bucket.rb', line 804

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