This gem adds simple sugar for ActiveSupport::Notifications
Subscribe to notifications
require 'instrumentation'
class UserNotifier
include Instrumentation
subscribe_to 'user.update'
def self.call(*event)
say "Processing..."
end
end
If you use Instrumentation by ActiveRecord model you can instrument model's changes and create one subscriber to all produced events
require 'instrumentation'
class User < ActiveRecord::Base
include Instrumentation
instrument_to 'models.mutations'
end
class ModelsMutationsSubscriber
include Instrumentation
subscribe_to(/models.*/)
def self.call(channel, _, _, _, payload)
end
end
Add this line to your application's Gemfile:
gem 'instrumentation', github: 'fatum/instrumentation'
And then execute:
$ bundle
Or install it yourself as:
$ gem install instrumentation
TODO: Write usage instructions here
- Fork it ( https://github.com/[my-github-username]/instrumentation/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request