--- layout: default title: Callbacks --- # Callbacks Besides all [ActiveJob callbacks](http://api.rubyonrails.org/classes/ActiveJob/Callbacks/ClassMethods.html), three other callbacks are available. You have access to [locals](/guides/locals) in all callbacks. ## `before_crawl` Fires __once__ before any pages have been retrieved. {% highlight ruby %} class DummyJob < Wayfarer::Job before_crawl { puts "Work is about to happen" } end {% endhighlight %} ## `after_crawl` Fires __once__ after all pages have been retrieved and processing is done. {% highlight ruby %} class DummyJob < Wayfarer::Job after_crawl { puts "Work did happen" } end {% endhighlight %} ## `setup_adapter` Fires for every adapter immediately after its creation. The block gets yielded an adapter. When using the Selenium HTTP adapter, both a WebDriver and a wrapping Capybara driver get yielded. {% highlight ruby %} class DummyJob < Wayfarer::Job config.http_adapter = :selenium config.connection_count = 4 setup_adapter do |adapter, driver, browser| # This block gets called 4 times with different adapters adapter # => The HTTP adapter driver # => # or nil browser # => # or nil end end {% endhighlight %}