Class: SmsGateway::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_gateway/base.rb,
lib/sms_gateway/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_gateway/base.rb', line 7

def adapter
  @adapter
end

.deliveriesObject

Returns the value of attribute deliveries.



7
8
9
# File 'lib/sms_gateway/adapters/test.rb', line 7

def deliveries
  @deliveries
end

.fromObject

Returns the value of attribute from.



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

def from
  @from
end

.keyObject

Returns the value of attribute key.



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

def key
  @key
end

.passwordObject

Returns the value of attribute password.



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

def password
  @password
end

.routeObject

Returns the value of attribute route.



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

def route
  @route
end

.userObject

Returns the value of attribute user.



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

def user
  @user
end

Class Method Details

.configObject



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

def config
  @config
end

.config=(options) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/sms_gateway/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:



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

def configure
  yield(self)
end

.deliver(sms) ⇒ Object



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

def deliver(sms)
  self.adapter.send_sms(sms)
end

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



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

def self.deliver_later(text, to, from=Base.config[:from]) 
  Resque.enqueue(SmsGateway::Workers::SmsJob, text, to, from) 
end