lib/google/cloud/spanner.rb in google-cloud-spanner-1.7.2 vs lib/google/cloud/spanner.rb in google-cloud-spanner-1.8.0
- old
+ new
@@ -70,20 +70,24 @@
#
# spanner = Google::Cloud::Spanner.new
#
def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
client_config: nil, project: nil, keyfile: nil
- project_id ||= (project || default_project_id)
- project_id = project_id.to_s # Always cast to a string
- raise ArgumentError, "project_id is missing" if project_id.empty?
-
- scope ||= configure.scope
- timeout ||= configure.timeout
+ project_id ||= (project || default_project_id)
+ scope ||= configure.scope
+ timeout ||= configure.timeout
client_config ||= configure.client_config
- credentials ||= (keyfile || default_credentials(scope: scope))
+ credentials ||= (keyfile || default_credentials(scope: scope))
+
unless credentials.is_a? Google::Auth::Credentials
credentials = Spanner::Credentials.new credentials, scope: scope
end
+
+ if credentials.respond_to? :project_id
+ project_id ||= credentials.project_id
+ end
+ project_id = project_id.to_s # Always cast to a string
+ raise ArgumentError, "project_id is missing" if project_id.empty?
Spanner::Project.new(
Spanner::Service.new(
project_id, credentials, timeout: timeout,
client_config: client_config