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
|