Class: SmsGate::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_gate/base.rb,
lib/sms_gate/adapters/test.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adapterObject

Returns the value of attribute adapter.



7
8
9
# File 'lib/sms_gate/base.rb', line 7

def adapter
  @adapter
end

.async_response_hooksObject

Returns the value of attribute async_response_hooks.



6
7
8
# File 'lib/sms_gate/base.rb', line 6

def async_response_hooks
  @async_response_hooks
end

.deliveriesObject

Returns the value of attribute deliveries.



5
6
7
# File 'lib/sms_gate/adapters/test.rb', line 5

def deliveries
  @deliveries
end

.fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/sms_gate/base.rb', line 6

def from
  @from
end

.passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/sms_gate/base.rb', line 6

def password
  @password
end

.userObject

Returns the value of attribute user.



6
7
8
# File 'lib/sms_gate/base.rb', line 6

def user
  @user
end

Class Method Details

.configObject



19
20
21
# File 'lib/sms_gate/base.rb', line 19

def config
  @config
end

.config=(options) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/sms_gate/base.rb', line 23

def config=(options)
  @config = options
  adapter = @config.delete(:adapter)
  @config.each do |k,v|
    self.send "#{k}=", v
  end
  self.adapter = adapter 
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (SmsGate::Base)

    the object that the method was called on



9
10
11
# File 'lib/sms_gate/base.rb', line 9

def configure
  yield(self)
end

.deliver(options) ⇒ Object



32
33
34
# File 'lib/sms_gate/base.rb', line 32

def deliver(options)
  self.adapter.send_sms(::SmsGate::Sms.new(options))
end

.deliver_later(text, to, from = Base.config[:from], model_id = -1)) ⇒ Object



36
37
38
# File 'lib/sms_gate/base.rb', line 36

def self.deliver_later(text, to, from = Base.config[:from], model_id = -1) 
  Resque.enqueue(::SmsGate::Jobs::SmsJob, text: text, to: to, from: from, model_id: model_id) 
end