Callbacks allow you to run code at various points of an object's lifecycle. For example, you may wish to execute code whenever a new ticket update is created or each time a user's properties are changed.
In order to add a callback to your module, you should define the following within your module class.
class Hipchat < Module add_callback :after, :ticket_update, :create do |config, ticket_update| ## All code in this block will be executed after a ticket update is created. ## ## As the :delayed => true options is present, this method will be executed by ## the Sirportly worker rather than in the live thread. All background scheduling ## is handled for you. If no :delayed option is present, the request will be run ## in the same thread which executed the requested action. end end
add_callback method takes three parameters, all three should be passed as Ruby symbols:
The block will be passed two objects, the
config which will be a hash of the configuration data entered by the user with the keys as symbols relating to the parameters you configured in
config_options. The second is the object which was associated with the event.