Class: Gcloud::Bigquery::Dataset::Updater

Inherits:
Gcloud::Bigquery::Dataset show all
Defined in:
lib/gcloud/bigquery/dataset.rb

Overview

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

Data collapse

Attributes inherited from Gcloud::Bigquery::Dataset

#gapi, #service

Data collapse

Methods inherited from Gcloud::Bigquery::Dataset

#api_url, #create_table, #create_view, #created_at, #dataset_id, #dataset_ref, #default_expiration, #default_expiration=, #delete, #description, #description=, #etag, from_gapi, #location, #modified_at, #name, #name=, #project_id, #query, #query_job, #table, #tables

Constructor Details

#initialize(gapi) ⇒ Updater

Create an Updater object.



712
713
714
715
# File 'lib/gcloud/bigquery/dataset.rb', line 712

def initialize gapi
  @updates = []
  @gapi = gapi
end

Instance Attribute Details

#updatesObject (readonly)

A list of attributes that were updated.



708
709
710
# File 'lib/gcloud/bigquery/dataset.rb', line 708

def updates
  @updates
end

Instance Method Details

#accessObject



717
718
719
720
721
722
723
724
725
726
# File 'lib/gcloud/bigquery/dataset.rb', line 717

def access
  # TODO: make sure to call ensure_full_data! on Dataset#update
  @access ||= Access.from_gapi @gapi
  if block_given?
    yield @access
    check_for_mutated_access!
  end
  # Same as Dataset#access, but not frozen
  @access
end

#check_for_mutated_access!Object

Make sure any access changes are saved



730
731
732
733
734
735
# File 'lib/gcloud/bigquery/dataset.rb', line 730

def check_for_mutated_access!
  return if @access.nil?
  return unless @access.changed?
  @gapi.update! access: @access.to_gapi
  patch_gapi! :access
end

#to_gapiObject



737
738
739
740
# File 'lib/gcloud/bigquery/dataset.rb', line 737

def to_gapi
  check_for_mutated_access!
  @gapi
end