Class: Gcloud::Datastore::Dataset::LookupResults

Inherits:
Array
  • Object
show all
Defined in:
lib/gcloud/datastore/dataset/lookup_results.rb

Overview

LookupResults is a special case Array with additional values. A LookupResults object is returned from Dataset#find_all and contains the entities as well as the Keys that were deferred from the results and the Entities that were missing in the dataset.

Please be cautious when treating the QueryResults as an Array. Many common Array methods will return a new Array instance.

Examples:

entities = dataset.find_all key1, key2, key3
entities.size #=> 3
entities.deferred #=> []
entities.missing #=> []

Caution, many Array methods will return a new Array instance:

entities = dataset.find_all key1, key2, key3
entities.size #=> 3
entities.deferred #=> []
entities.missing #=> []
names = entities.map { |e| e["name"] }
names.size #=> 3
names.deferred #=> NoMethodError
names.missing #=> NoMethodError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arr = [], deferred = [], missing = []) ⇒ LookupResults

Create a new LookupResults with an array of values.


57
58
59
60
61
# File 'lib/gcloud/datastore/dataset/lookup_results.rb', line 57

def initialize arr = [], deferred = [], missing = []
  super arr
  @deferred = deferred
  @missing = missing
end

Instance Attribute Details

#deferredObject

Keys that were not looked up due to resource constraints.


49
50
51
# File 'lib/gcloud/datastore/dataset/lookup_results.rb', line 49

def deferred
  @deferred
end

#missingObject

Entities not found, with only the key populated.


53
54
55
# File 'lib/gcloud/datastore/dataset/lookup_results.rb', line 53

def missing
  @missing
end