class NotificationGateway::Pubnub

Attributes

channel[RW]
logger[RW]
message[RW]
options[RW]
publish_key[RW]
pubnub[RW]
subscribe_key[RW]

Public Class Methods

new(**options) click to toggle source
# File lib/notification_gateway/pubnub.rb, line 4
def initialize **options
  @options       = options
  @subscribe_key = options[:subscribe_key]
  @publish_key   = options[:publish_key]
  @logger        = set_logger

  raise "publish_key is missing"   unless publish_key
  raise "subscribe_key is missing" unless subscribe_key
  
  @pubnub = Pubnub.new(
    subscribe_key: @subscribe_key,
    publish_key:   @publish_key,
    logger: @logger
  )
end

Public Instance Methods

publish(channel:, message: pubnub.publish( channel: channel, message: message) click to toggle source
# File lib/notification_gateway/pubnub.rb, line 20
def publish channel:, message:  
  pubnub.publish(
    channel: channel,
    message: message
  ) {|envelope| }# puts envelope.status}
end
set_logger() click to toggle source
# File lib/notification_gateway/pubnub.rb, line 27
def set_logger
  options[:logger] || ActiveSupport::Logger.new(options[:logger_path]) 
end