Skip to content

Instantly share code, notes, and snippets.

@tanvir002700
Last active November 10, 2016 15:08
Show Gist options
  • Save tanvir002700/e7f7ddb05d774e4d47d3df4e0970bf32 to your computer and use it in GitHub Desktop.
Save tanvir002700/e7f7ddb05d774e4d47d3df4e0970bf32 to your computer and use it in GitHub Desktop.
Ruby singleton class for pubnub push notification.
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