Class: Google::Cloud::Bigquery::Dataset::Updater

Inherits:
Google::Cloud::Bigquery::Dataset show all
Defined in:
lib/google/cloud/bigquery/dataset.rb

Overview

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

Data collapse

Data collapse

Methods inherited from Google::Cloud::Bigquery::Dataset

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

Constructor Details

#initialize(gapi) ⇒ Updater

Create an Updater object.



864
865
866
867
# File 'lib/google/cloud/bigquery/dataset.rb', line 864

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

Instance Attribute Details

#updatesObject (readonly)

A list of attributes that were updated.



860
861
862
# File 'lib/google/cloud/bigquery/dataset.rb', line 860

def updates
  @updates
end

Instance Method Details

#accessObject



869
870
871
872
873
874
875
876
877
878
# File 'lib/google/cloud/bigquery/dataset.rb', line 869

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



882
883
884
885
886
887
# File 'lib/google/cloud/bigquery/dataset.rb', line 882

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



889
890
891
892
# File 'lib/google/cloud/bigquery/dataset.rb', line 889

def to_gapi
  check_for_mutated_access!
  @gapi
end