Module: ActiveRecord::Bitemporal::Patches::ThroughAssociation

Defined in:
lib/activerecord-bitemporal/patches.rb

Instance Method Summary collapse

Instance Method Details

#target_scopeObject



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/activerecord-bitemporal/patches.rb', line 97

def target_scope
  scope = super
  return scope unless scope.bi_temporal_model?

  reflection.chain.drop(1).each do |reflection|
    klass = reflection.klass&.scope_for_association&.klass
    next unless klass&.bi_temporal_model?
    scope.bitemporal_value[:through] = klass
  end
  scope
end