# Rails 3 and ActiveSupport::Callbacks

**URL:** <https://www.ruby-forum.com/t/rails-3-and-activesupport-callbacks/190877>\
**Category:** Rails\
**Created:** [June 29, 2010, 8:12pm UTC](https://www.ruby-forum.com/t/rails-3-and-activesupport-callbacks/190877 "2010-06-29T20:12:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@jdv](https://www.ruby-forum.com/u/jdv)\
**Post date:** [June 29, 2010, 8:12pm UTC](https://www.ruby-forum.com/t/rails-3-and-activesupport-callbacks/190877/1 "2010-06-29T20:12:05Z")

</div>

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!
