Skip to content

Commit

Permalink
Rename Service#datastore and Service#mocked_datastore
Browse files Browse the repository at this point in the history
Adopt 'service' and 'mocked_service' naming convention.
  • Loading branch information
quartzmo committed Oct 7, 2016
1 parent 5cfd614 commit 1aa0a15
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 109 deletions.
20 changes: 10 additions & 10 deletions google-cloud-datastore/lib/google/cloud/datastore/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize project, credentials, host: nil, retries: nil,
timeout: nil
@project = project
@credentials = credentials
@host = host || "datastore.googleapis.com"
@host = host || V1::DatastoreApi::SERVICE_ADDRESS
@retries = retries
@timeout = timeout
end
Expand All @@ -43,16 +43,16 @@ def creds
GRPC::Core::CallCredentials.new credentials.client.updater_proc
end

def datastore
return mocked_datastore if mocked_datastore
def service
return mocked_service if mocked_service
@datastore ||= begin
require "google/datastore/v1/datastore_services_pb"

Google::Datastore::V1::Datastore::Stub.new(
host, creds, timeout: timeout)
end
end
attr_accessor :mocked_datastore
attr_accessor :mocked_service

def insecure?
credentials == :this_channel_is_insecure
Expand All @@ -67,7 +67,7 @@ def allocate_ids *incomplete_keys
keys: incomplete_keys
)

execute { datastore.allocate_ids allocate_req }
execute { service.allocate_ids allocate_req }
end

##
Expand All @@ -80,7 +80,7 @@ def lookup *keys, consistency: nil, transaction: nil
lookup_req.read_options = generate_read_options consistency,
transaction

execute { datastore.lookup lookup_req }
execute { service.lookup lookup_req }
end

# Query for entities.
Expand All @@ -99,7 +99,7 @@ def run_query query, namespace = nil, consistency: nil, transaction: nil
run_req.partition_id = Google::Datastore::V1::PartitionId.new(
namespace_id: namespace) if namespace

execute { datastore.run_query run_req }
execute { service.run_query run_req }
end

##
Expand All @@ -109,7 +109,7 @@ def begin_transaction
project_id: project
)

execute { datastore.begin_transaction tx_req }
execute { service.begin_transaction tx_req }
end

##
Expand All @@ -126,7 +126,7 @@ def commit mutations, transaction: nil
commit_req.transaction = transaction
end

execute { datastore.commit commit_req }
execute { service.commit commit_req }
end

##
Expand All @@ -137,7 +137,7 @@ def rollback transaction
transaction: transaction
)

execute { datastore.rollback rb_req }
execute { service.rollback rb_req }
end

def inspect
Expand Down
Loading

0 comments on commit 1aa0a15

Please sign in to comment.