Hi.
Is there a way to access an object within callbacks defined with set_callback (ActiveSupport 3.0.0-beta4, matching Rails 3)?
Use case is as follow:
require 'active_support'
class Foo include ActiveSupport::Callbacks
define_callbacks :handle_response
set_callback :handle_response, :after do |response| # play with the response end
# some stuff...
def list_users run_callbacks :handle_response do # this request returns a response @someapi.get("/some/resource") end end end
# run Foo.new.list_users
Currently, in place of |response|, I have |object| as the doc suggests, which is the class object at runtime. AS callbacks are great for after/before/around independant processing, but can they be used for data manipulation hooks? If not, is there an alternative to achieve such an effect?
Thank you!