Skip to content

fatum/instrumentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instrumentation

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

Installation

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

Usage

TODO: Write usage instructions here

Contributing

  1. Fork it ( https://github.com/[my-github-username]/instrumentation/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Little sugar for ActiveSupport::Notifications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages