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

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

Instance Method Summary collapse

Instance Method Details

#target_scopeObject



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/activerecord-bitemporal/patches.rb', line 85

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