Class: SmsClub::AsyncClient
Instance Attribute Summary collapse
-
#queue ⇒ Object
Returns the value of attribute queue.
Attributes inherited from Client
#from, #password, #transliterate, #user_name
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ AsyncClient
constructor
A new instance of AsyncClient.
- #send_async(message, options = {}) ⇒ Object
Methods inherited from Client
#send_many, #send_one, #status_for, #statuses_for
Constructor Details
#initialize(*args) ⇒ AsyncClient
Returns a new instance of AsyncClient.
12 13 14 15 |
# File 'lib/sms-club/async.rb', line 12 def initialize(*args) @init_args = args super end |
Instance Attribute Details
#queue ⇒ Object
Returns the value of attribute queue.
10 11 12 |
# File 'lib/sms-club/async.rb', line 10 def queue @queue end |
Class Method Details
.perform(init_args, message, msg_options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sms-club/async.rb', line 31 def self.perform(init_args, , ) # Ugliness level 99. Needed to pass args to constructor # when Resque instantiate AsyncClient user_name, password, = init_args # Resque serializes params to json, so symbols are # converted to strings, which is not what we want puts new(user_name, password, .symbolize_keys!) .send_many(, .symbolize_keys!) end |
.queue ⇒ Object
17 18 19 |
# File 'lib/sms-club/async.rb', line 17 def self.queue 'sms_club' end |
Instance Method Details
#send_async(message, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/sms-club/async.rb', line 21 def send_async(, = {}) begin Resque.enqueue(self.class, @init_args, , ) rescue Redis::CannotConnectError => e warn e warn 'Can not connect to redis server. Falling back to synchronous mode.' send_many , end end |