Skip to content

Commit

Permalink
Merge pull request #623 from DNNX/bypass-for-real
Browse files Browse the repository at this point in the history
Improve performance of bypassing
  • Loading branch information
pyromaniac authored Jan 11, 2018
2 parents e2a62dd + b0dcf08 commit 25db17c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/chewy/type/observe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ def update_proc(type_name, *args, &block)
method = args.first

proc do
backreference = if method && method.to_s == 'self'
self
elsif method
send(method)
else
instance_eval(&block)
end

reference = if type_name.is_a?(Proc)
if type_name.arity.zero?
instance_exec(&type_name)
Expand All @@ -27,7 +19,19 @@ def update_proc(type_name, *args, &block)
type_name
end

Chewy.derive_type(reference).update_index(backreference, options)
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

Expand Down

0 comments on commit 25db17c

Please sign in to comment.