Last active
November 10, 2016 15:08
-
-
Save tanvir002700/e7f7ddb05d774e4d47d3df4e0970bf32 to your computer and use it in GitHub Desktop.
Ruby singleton class for pubnub push notification.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'singleton' | |
class PubnubSingleton | |
include Singleton | |
attr_accessor :pubnub | |
def initialize | |
@pubnub = Pubnub.new( | |
publish_key: ENV['PUBNUB_PUBLISH_KEY'], | |
subscribe_key: ENV['PUBNUB_SUBSCRIBE_KEY'], | |
secret_key: ENV['PUBNUB_SECRET_KEY'], | |
logger: Rails.logger | |
) | |
end | |
def self.client | |
self.instance.pubnub | |
end | |
end | |
# It will be send notification by this format | |
# PubnubSingleton.client.publish(message: message, channel: station) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment