14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/acts_as_paranoid/associations.rb', line 14
def belongs_to_with_deleted(target, scope = nil, options = {})
if scope.is_a?(Hash)
options = scope
scope = nil
end
with_deleted = options.delete(:with_deleted)
if with_deleted
original_scope = scope
scope = make_scope_with_deleted(scope)
end
result = belongs_to_without_deleted(target, scope, **options)
if with_deleted
options = result.values.last.options
options[:with_deleted] = with_deleted
options[:original_scope] = original_scope
end
result
end
|