7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/chewy/type/observe.rb', line 7
def update_proc(type_name, *args, &block)
options = args.
method = args.first
proc do
reference = if type_name.is_a?(Proc)
if type_name.arity.zero?
instance_exec(&type_name)
else
type_name.call(self)
end
else
type_name
end
type = Chewy.derive_type(reference)
next if Chewy.strategy.current.name == :bypass
backreference = if method && method.to_s == 'self'
self
elsif method
send(method)
else
instance_eval(&block)
end
type.update_index(backreference, options)
end
end
|