lib/google/cloud/storage/bucket.rb in google-cloud-storage-1.30.0 vs lib/google/cloud/storage/bucket.rb in google-cloud-storage-1.31.0

- old
+ new

@@ -307,11 +307,11 @@ # @return [String] # # @see https://cloud.google.com/storage/docs/access-logs Access Logs # def logging_bucket - @gapi.logging.log_bucket if @gapi.logging + @gapi.logging&.log_bucket end ## # Updates the destination bucket for the bucket's logs. # @@ -331,11 +331,11 @@ # @see https://cloud.google.com/storage/docs/access-logs Access Logs # # @return [String] # def logging_prefix - @gapi.logging.log_object_prefix if @gapi.logging + @gapi.logging&.log_object_prefix end ## # Updates the logging object prefix. This prefix will be used to create # log object names for the bucket. It can be at most 900 characters and @@ -390,11 +390,11 @@ # is enabled for the bucket. # # @return [Boolean] # def versioning? - @gapi.versioning.enabled? unless @gapi.versioning.nil? + @gapi.versioning&.enabled? end ## # Updates whether [Object # Versioning](https://cloud.google.com/storage/docs/object-versioning) @@ -420,11 +420,11 @@ # How to Host a Static Website # # @return [String] The main page suffix. # def website_main - @gapi.website.main_page_suffix if @gapi.website + @gapi.website&.main_page_suffix end ## # Updates the main page suffix for a static website. # @@ -447,11 +447,11 @@ # How to Host a Static Website # # @return [String] # def website_404 - @gapi.website.not_found_page if @gapi.website + @gapi.website&.not_found_page end ## # A hash of user-provided labels. The hash is frozen and changes are not # allowed. @@ -496,11 +496,11 @@ # # @return [Boolean, nil] Returns `true` if requester pays is enabled for # the bucket. # def requester_pays - @gapi.billing.requester_pays if @gapi.billing + @gapi.billing&.requester_pays end alias requester_pays? requester_pays ## # Enables requester pays for the bucket. If enabled, a client accessing @@ -548,11 +548,11 @@ # bucket.default_kms_key = kms_key_name # # bucket.default_kms_key #=> kms_key_name # def default_kms_key - @gapi.encryption && @gapi.encryption.default_kms_key_name + @gapi.encryption&.default_kms_key_name end ## # Set the Cloud KMS encryption key that will be used to protect files. # For example: `projects/a/locations/b/keyRings/c/cryptoKeys/d` @@ -597,11 +597,11 @@ # # @return [Integer, nil] The retention period defined in seconds, if a # retention policy exists for the bucket. # def retention_period - @gapi.retention_policy && @gapi.retention_policy.retention_period + @gapi.retention_policy&.retention_period end ## # The period of time (in seconds) that files in the bucket must be # retained, and cannot be deleted, overwritten, or archived. Passing a @@ -656,11 +656,11 @@ # # @return [DateTime, nil] The effective date of the bucket's retention # policy, if a policy exists. # def retention_effective_at - @gapi.retention_policy && @gapi.retention_policy.effective_time + @gapi.retention_policy&.effective_time end ## # Whether the bucket's file retention policy is locked and its retention # period cannot be reduced. See {#retention_period=} and @@ -806,11 +806,11 @@ # # bucket.uniform_bucket_level_access = true # bucket.uniform_bucket_level_access? # true # def uniform_bucket_level_access? - return false unless @gapi.iam_configuration && @gapi.iam_configuration.uniform_bucket_level_access + return false unless @gapi.iam_configuration&.uniform_bucket_level_access !@gapi.iam_configuration.uniform_bucket_level_access.enabled.nil? && @gapi.iam_configuration.uniform_bucket_level_access.enabled end ## @@ -868,11 +868,11 @@ # # # The deadline for disabling uniform bucket-level access. # puts bucket.uniform_bucket_level_access_locked_at # def uniform_bucket_level_access_locked_at - return nil unless @gapi.iam_configuration && @gapi.iam_configuration.uniform_bucket_level_access + return nil unless @gapi.iam_configuration&.uniform_bucket_level_access @gapi.iam_configuration.uniform_bucket_level_access.locked_time end ## # @deprecated Use {#uniform_bucket_level_access?} instead. @@ -2570,12 +2570,14 @@ ## # Yielded to a block to accumulate changes for a patch request. class Updater < Bucket attr_reader :updates + ## # Create an Updater object. def initialize gapi + super() @updates = [] @gapi = gapi @labels = @gapi.labels.to_h.dup @cors_builder = nil @lifecycle_builder = nil