Module: ActiveRecord::Bitemporal::Patches::Association

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

Instance Method Summary collapse

Instance Method Details

#scopeObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/activerecord-bitemporal/patches.rb', line 56

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

  scope_ = scope
  if owner.class&.bi_temporal_model?
    if owner.valid_datetime
      valid_datetime = owner.valid_datetime
      scope_ = scope_.valid_at(valid_datetime)
      scope_.merge!(scope_.bitemporal_value[:through].valid_at(valid_datetime)) if scope_.bitemporal_value[:through]
    end

    if owner.transaction_datetime
      transaction_datetime = owner.transaction_datetime
      scope_ = scope_.transaction_at(transaction_datetime)
      scope_.merge!(scope_.bitemporal_value[:through].transaction_at(transaction_datetime)) if scope_.bitemporal_value[:through]
    end
  end
  return scope_
end

#skip_statement_cache?(scope) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/activerecord-bitemporal/patches.rb', line 52

def skip_statement_cache?(scope)
  super || bi_temporal_model?
end