# class GlobalID::Locator::BaseLocator

### Public Instance Methods

locate(gid) click to toggle source

    # File lib/global_id/locator.rb, line 129
    def locate(gid)
      gid.model_class.find gid.model_id
    end

locate_many(gids, options = {}) click to toggle source

    # File lib/global_id/locator.rb, line 133
    def locate_many(gids, options = {})
      models_and_ids  = gids.collect { |gid| [ gid.model_class, gid.model_id ] }
      ids_by_model    = models_and_ids.group_by(&:first)
      loaded_by_model = Hash[ids_by_model.map { |model, ids|
        [ model, find_records(model, ids.map(&:last), ignore_missing: options[:ignore_missing]).index_by { |record| record.id.to_s } ]
      }]

      models_and_ids.collect { |(model, id)| loaded_by_model[model][id] }.compact
    end

### Private Instance Methods

find_records(model_class, ids, options) click to toggle source

    # File lib/global_id/locator.rb, line 144
    def find_records(model_class, ids, options)
      if options[:ignore_missing]
        model_class.where(id: ids)
      else
        model_class.find(ids)
      end
    end