Permalink
Browse files

around callback works! yay!

  • Loading branch information...
1 parent 6a7c916 commit 80dea1fcc9f57be39b7d90b261155eee923eacf7 Sidharta Surya Kusnanto committed Mar 10, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/tire/configuration.rb
View
8 lib/tire/configuration.rb
@@ -59,15 +59,17 @@ def self.nest(*args)
end
unless associated_class.respond_to? "refresh_#{root_class.to_s.underscore}_indexes".to_sym
if delayed_job
- associated_class.send(:define_method, "refresh_#{root_class.to_s.underscore}_indexes".to_sym) do
+ associated_class.send(:define_method, "refresh_#{root_class.to_s.underscore}_indexes".to_sym) do |&block|
+ block.call
Tire::Job::ReindexJob.queue(root_class, associated_class, self.id)
end
else
- associated_class.send(:define_method, "refresh_#{root_class.to_s.underscore}_indexes".to_sym) do
+ associated_class.send(:define_method, "refresh_#{root_class.to_s.underscore}_indexes".to_sym) do |&block|
+ block.call
Tire::Job::ReindexJob.new(root_class, associated_class, self.id).perform
end
end
- associated_class.set_callback :update, :after, "refresh_#{root_class.to_s.underscore}_indexes".to_sym
+ associated_class.set_callback :update, :around, "refresh_#{root_class.to_s.underscore}_indexes".to_sym
end
end
end

0 comments on commit 80dea1f

Please sign in to comment.