Class: SmsGate::Sms

Inherits:
Struct
  • Object
show all
Defined in:
lib/sms_gate/sms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Sms

Returns a new instance of Sms.



4
5
6
7
8
9
# File 'lib/sms_gate/sms.rb', line 4

def initialize(params)
  self.from = params[:from] || ::SmsGate::Base.from
  self.to = params[:to]
  self.text = params[:text]
  self.model_id = params[:model_id]
end

Instance Attribute Details

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



2
3
4
# File 'lib/sms_gate/sms.rb', line 2

def from
  @from
end

#model_idObject

Returns the value of attribute model_id

Returns:

  • (Object)

    the current value of model_id



2
3
4
# File 'lib/sms_gate/sms.rb', line 2

def model_id
  @model_id
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



2
3
4
# File 'lib/sms_gate/sms.rb', line 2

def text
  @text
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



2
3
4
# File 'lib/sms_gate/sms.rb', line 2

def to
  @to
end

Instance Method Details

#deliverObject



11
12
13
# File 'lib/sms_gate/sms.rb', line 11

def deliver
  ::SmsGate::Base.deliver(to: self.to, from: self.from, text: self.text)
end

#deliver_laterObject



15
16
17
# File 'lib/sms_gate/sms.rb', line 15

def deliver_later
  Resque.enqueue(::SmsGate::Jobs::SmsJob, to: self.to, from: self.from, text: self.text, model_id: self.model_id)
end

#to_sObject



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

def to_s
  "SMS: from:#{self.from}, to:#{self.to}, text:#{self.text}, model_id:#{self.model_id}"
end