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!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.