Class: SmsSafe::Interceptors::ActionTexter

Inherits:
SmsSafe::Interceptor show all
Defined in:
lib/sms_safe/interceptors/action_texter.rb

Instance Method Summary collapse

Methods inherited from SmsSafe::Interceptor

#discard, #email, #email_recipient, #intercept_message!, #intercept_message?, #process_message, #redirect_phone_number, #redirect_text

Instance Method Details

#convert_message(message) ⇒ Message

Converts an ActionTexter::Message into an SmsSafe::Message


14
15
16
# File 'lib/sms_safe/interceptors/action_texter.rb', line 14

def convert_message(message)
  SmsSafe::Message.new(from: message.from, to: message.to, text: message.text, original_message: message)
end

#delivering_sms(message) ⇒ Object

This method will be called differently for each Texter Gem, it's the one that the hook likes to call In all cases, it's a one-liner that calls process_message in the superclass It could even be an alias, for all practical purposes


7
8
9
# File 'lib/sms_safe/interceptors/action_texter.rb', line 7

def delivering_sms(message)
  self.process_message(message)
end

#redirect(message) ⇒ ActionTexter::Message

Returns a modified version of the original message with new recipient and text,

to give back to the texter gem to send.

24
25
26
27
28
29
# File 'lib/sms_safe/interceptors/action_texter.rb', line 24

def redirect(message)
  original_message = message.original_message
  original_message.to = redirect_phone_number(message)
  original_message.text = redirect_text(message)
  original_message
end