Module: AssociateJsonb::Associations::Preloader::Association

Defined in:
lib/associate_jsonb/associations/preloader/association.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#records_for(ids) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/associate_jsonb/associations/preloader/association.rb', line 8

def records_for(ids)
  return super if reflection.belongs_to?
  return super unless reflection.foreign_store?

  table = reflection.klass.arel_table
  scope.where(
    Arel::Nodes::Jsonb::HashArrow.new(
      table,
      table[reflection.foreign_store_attr],
      reflection.foreign_store_key
    ).intersects_with(ids)
  )
end