hookly-rails

Circle CI
Gem Version

  1. Ruby wrapper for the Hookly API
  2. hookly.js asset pipeline provider/wrapper

Rails 3.1+ asset-pipeline gem to provide hookly.js

Setup

Add to your Gemfile:

gem 'hookly-rails'

JS Setup

Then add this to you application.js manifest:

//= require hookly

Then check out the hookly.js docs for usage and working examples

API Setup

# config/initializers/hookly.rb
Hookly.token = '{{token}}'
Hookly.secret = '{{secret}}'

Post a message to the #updates channel

In the client javascript subscribe to '#updates'

hookly.setup('{{token}}')
hookly.on('#updates', function(options) {
  // options == { model: 'Message', id: 5, text: 'Thanks for the info.' }
});

Push a new message the updates channel

Hookly::Message.create('#updates', model: 'Message', id: 5, text: 'Thanks for the info.')
 #=> #<Hookly::Message id: '44fjwq-djas' slug: '#updates', data: { model: 'Message', id: 5, text: 'Thanks for the info.' }>

Post a private message

Have information that only a certain user should see??

Include a unique user id on the client and server

hookly.setup('{{token}}', '{{uid}}')
hookly.on('#updates', function(options) {
  // options == { model: 'Message', id: 6, text: 'Thanks for the PRIVATE info.' }
});
Hookly::Message.create('#updates', '{{uid}}', id: 6, text: 'Thanks for the PRIVATE info.')
 #=> #<Hookly::Message id: '44fjwq-djas' slug: '#updates', uid: '{{uid}}' data: { model: 'Message', id: 6, text: 'Thanks for the PRIVATE info.' }>