Project

paper_boy

0.0
No commit activity in last 3 years
No release in over 3 years
Automatically deliver notifications to subscribers from controllers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

PaperBoy

Automatically deliver notifications to subscribers from controllers (lightweight mixin using ActiveSupport::Notifications)

Installation

Add this line to your application's Gemfile:

gem 'paper_boy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paper_boy

Usage

At first, execute install command:

$ bin/rails g paper_boy:install

Include PaperBoy in ApplicationController:

class ApplicationController < ActionController::Base
  include PaperBoy
end

And you generate subscriber class with generator command:

$ bin/rails g paper_boy:subscriber

Then you implement app/subscribers/users_subscriber.rb:

class UsersSubscriber < ApplicationSubscriber
  def create(event)
    payload = event.payload

    # All instance variables are set from controller class.
    user = payload[:current_user]

    # implement something (mailer, notifier, logger ...etc)
    logger.info user
  end

  attach_to :"users"
end

License

MIT License