module GlobalID::Locator
def locate_many(gids, options = {})
#find will raise an exception if a named ID can't be found. When you set this option to true,
ids extracted from the GIDs. In Active Record (and other data stores following the same pattern),
* :ignore_missing - By default, locate_many will call #find on the model to locate the
modules match, +nil+ is returned.
instances of returned classes to those including that module. If no classes or
classes to those classes or their subclasses. Passing one or more modules in limits
allowed to be located. Passing one or more classes limits instances of returned
* :only - A class, module or Array of classes and/or modules that are
Options:
per model class, but still interpolate the results to match the order in which the gids were passed.
This approach will efficiently call only one #find (or #where(id: id), when using ignore_missing)
models must respond to that finder signature.
By default the GlobalIDs will be located using Model.find(array_of_ids), so the
the same locator using its locate_many method.
All GlobalIDs must belong to the same app, as they will be located using
Takes an array of GlobalIDs or strings that can be turned into a GlobalIDs.
def locate_many(gids, options = {}) if (allowed_gids = parse_allowed(gids, options[:only])).any? locator = locator_for(allowed_gids.first) locator.locate_many(allowed_gids, options) else [] end end