Method: ActiveModel::Datastore::ClassMethods#find_entities
- Defined in:
- lib/active_model/datastore.rb
#find_entities(*ids_or_names, parent: nil) ⇒ Array<Entity>
Retrieves the entities for the provided ids by key and by an optional parent. The find_all method returns LookupResults, which is a special case Array with additional values. LookupResults are returned in batches, and the batch size is determined by the Datastore API. Batch size is not guaranteed. It will be affected by the size of the data being returned, and by other forces such as how distributed and/or consistent the data in Datastore is. Calling all on the LookupResults retrieves all results by repeatedly loading #next until #next? returns false. The all method returns an enumerator unless passed a block. We iterate on the enumerator to return the model entity objects.
251 252 253 254 255 |
# File 'lib/active_model/datastore.rb', line 251 def find_entities(*ids_or_names, parent: nil) ids_or_names = ids_or_names.flatten.compact.uniq lookup_results = find_all_entities(ids_or_names, parent) lookup_results.all.collect { |x| x } end |