Module: Airtable::ORM::Associations

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/airtable/orm/associations.rb

Class Method Summary collapse

Class Method Details

.fetch_linked_records(klass, ids) ⇒ Object

Fetch linked records via find_many, slicing to its per-request ID cap so an association (or preload union) with more links than the cap still loads.



10
11
12
13
14
# File 'lib/airtable/orm/associations.rb', line 10

def self.fetch_linked_records(klass, ids)
  records = ids.each_slice(Airtable::ORM::Persistence::MAX_FIND_MANY_IDS)
               .flat_map { |slice| klass.find_many(slice).to_a }
  Airtable::ORM::Collection.new(records, model_class: klass)
end