lib/google/cloud/firestore/transaction.rb in google-cloud-firestore-0.20.0 vs lib/google/cloud/firestore/transaction.rb in google-cloud-firestore-0.21.0

- old
+ new

@@ -72,11 +72,11 @@ # # @return [Client] firestore client. def firestore @client end - alias_method :client, :firestore + alias client firestore # @!group Access ## # Retrieves a list of document snapshots. @@ -118,13 +118,13 @@ extract_transaction_from_result! result next if result.result.nil? yield DocumentSnapshot.from_batch_result(result, self) end end - alias_method :get_docs, :get_all - alias_method :get_documents, :get_all - alias_method :find, :get_all + alias get_docs get_all + alias get_documents get_all + alias find get_all ## # Retrieves document snapshots for the given value. Valid values can be # a string representing either a document or a collection of documents, # a document reference object, a collection reference object, or a query @@ -231,11 +231,11 @@ extract_transaction_from_result! result next if result.document.nil? yield DocumentSnapshot.from_query_result(result, self) end end - alias_method :run, :get + alias run get # @!endgroup # @!group Modifications @@ -560,11 +560,12 @@ ensure_not_closed! doc_path = coalesce_doc_path_argument doc @writes << Convert.write_for_delete( - doc_path, exists: exists, update_time: update_time) + doc_path, exists: exists, update_time: update_time + ) nil end # @!endgroup @@ -635,21 +636,17 @@ end ## # @private def coalesce_get_argument obj - if obj.is_a?(String) || obj.is_a?(Symbol) - if obj.to_s.split("/").count.even? - return client.doc obj # Convert a DocumentReference - else - return client.col obj # Convert to CollectionReference - end - end - return obj.ref if obj.is_a? DocumentSnapshot - obj + return obj unless obj.is_a?(String) || obj.is_a?(Symbol) + + return client.doc obj if obj.to_s.split("/").count.even? + + client.col obj # Convert to CollectionReference end ## # @private def coalesce_doc_path_argument doc_path @@ -693,11 +690,11 @@ end ## # @private def ensure_not_closed! - fail "transaction is closed" if closed? + raise "transaction is closed" if closed? end ## # @private Raise an error unless an database available. def ensure_transaction_id! @@ -709,17 +706,17 @@ end ## # @private Raise an error unless an database available. def ensure_client! - fail "Must have active connection to service" unless firestore + raise "Must have active connection to service" unless firestore end ## # @private Raise an error unless an active connection to the service # is available. def ensure_service! - fail "Must have active connection to service" unless service + raise "Must have active connection to service" unless service end end end end end