Class: PUNK::SendSmsWorker
- Defined in:
- lib/punk/workers/send_sms_worker.rb
Instance Attribute Summary
Attributes included from Validatable
Instance Method Summary collapse
Methods inherited from Worker
Methods inherited from Runnable
args, #method_missing, #respond_to_missing?
Methods included from Validatable
#default_validation_helpers_options, #get_column_value, #valid?, #validates_not_empty
Methods included from Plugins::Validation::InstanceMethods
#validates_email, #validates_event, #validates_phone, #validates_state, #validates_url
Methods inherited from Settings
#method_missing, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PUNK::Runnable
Instance Method Details
#process ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/punk/workers/send_sms_worker.rb', line 15 def process if PUNK.env.test? || PUNK.get.plivo.mock plivo = PUNK.cache.get(:plivo) || [] = { sent: Time.now.utc.to_s, from: PUNK.get.plivo.number, to: to, body: body } plivo.prepend() PUNK.cache.set(:plivo, plivo) unless PUNK.env.test? require 'launchy' Launchy.open("#{PUNK.get.app.url || 'http://localhost:3000'}/plivo.html") end return end require 'plivo' client = Plivo::RestClient.new(PUNK.get.plivo.auth_id, PUNK.get.plivo.auth_token) client..create(PUNK.get.plivo.number, [to], body) end |
#validate ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/punk/workers/send_sms_worker.rb', line 7 def validate validates_type String, :to validates_phone :to validates_includes PUNK.get.plivo.whitelist, :to if !PUNK.env.test? && !PUNK.get.plivo.mock && PUNK.get.plivo.whitelist.present? validates_type String, :body validates_length_range 1..1600, :body end |