class SmsClub::AsyncClient

Attributes

queue[RW]

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/sms-club/async.rb, line 12
def initialize(*args)
  @init_args = args
  super
end
perform(init_args, message, msg_options) click to toggle source
# File lib/sms-club/async.rb, line 31
def self.perform(init_args, message, msg_options)
  # Ugliness level 99. Needed to pass args to constructor
  # when Resque instantiate AsyncClient
  user_name, password, options = init_args

  # Resque serializes params to json, so symbols are
  # converted to strings, which is not what we want
  puts new(user_name, password, options.symbolize_keys!)
          .send_many(message, msg_options.symbolize_keys!)
end
queue() click to toggle source
# File lib/sms-club/async.rb, line 17
def self.queue
  'sms_club'
end

Public Instance Methods

send_async(message, options = {}) click to toggle source
# File lib/sms-club/async.rb, line 21
def send_async(message, options = {})
  begin
    Resque.enqueue(self.class, @init_args, message, options)
  rescue Redis::CannotConnectError => e
    warn e
    warn 'Can not connect to redis server. Falling back to synchronous mode.'
    send_many message, options
  end
end