Module: SmsSafe

Defined in:
lib/sms_safe/hooks.rb,
lib/sms_safe/config.rb,
lib/sms_safe/version.rb,
lib/sms_safe/message.rb,
lib/sms_safe/interceptor.rb,
lib/sms_safe/interceptors/nexmo.rb,
lib/sms_safe/interceptors/twilio.rb,
lib/sms_safe/interceptors/action_texter.rb

Defined Under Namespace

Modules: Interceptors Classes: Configuration, Interceptor, InvalidConfigSettingError, Message

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.configurationObject


5
6
7
# File 'lib/sms_safe/config.rb', line 5

def self.configuration
  @configuration ||=  Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:


9
10
11
# File 'lib/sms_safe/config.rb', line 9

def self.configure
  yield(configuration) if block_given?
end

.hook!(texter_gem) ⇒ Object

Hooks into the specified texter gem to be able to analyze and modify / discard messages before they are sent.

Uses a civilized method for :action_texter, and monkey_patching for the rest, unfortunately

Parameters:

  • texter_gem (Symbol)

    the gem that is being used for sending messages. Can be :action_texter, :twilio, or :nexmo

Returns:

  • Nothing useful


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sms_safe/hooks.rb', line 9

def self.hook!(texter_gem)
  case texter_gem
    when :action_texter
      ActionTexter.register_interceptor(SmsSafe::Interceptors::ActionTexter.new)
    when :twilio
      hook_twilio!
    when :nexmo
      hook_nexmo!
    else
      raise InvalidConfigSettingError.new("Ensure texter_gem is either :action_texter, :twilio or :nexmo")
  end
end