Class: SmsSafe::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_safe/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration


43
44
45
46
47
# File 'lib/sms_safe/config.rb', line 43

def initialize
  @internal_phone_numbers = []
  @intercept_mechanism = 'redirect'
  @discard_delay = 50 # 50 milliseconds
end

Instance Attribute Details

#discard_delayObject

If you are doing stress testing, you don't want to send out millions of SMS or Emails, so discarding is the

way to go. However, this may give you an unrealistic view of how many SMS you can send per minute, distorting
the results of the stress test. Discard delay introduces a little `sleep` whilst discarding, to compensate for that.

Defaults to 50ms Specify it in ms


41
42
43
# File 'lib/sms_safe/config.rb', line 41

def discard_delay
  @discard_delay
end

#email_targetObject

The target email where messages are sent, instead of sending SMS, if intercept mechanism is :email Value can be a string or a Proc that returns a string


34
35
36
# File 'lib/sms_safe/config.rb', line 34

def email_target
  @email_target
end

#intercept_mechanismObject

What to do with intercepted messages. Options are:

:redirect - send SMS to another number. Must set redirect_target option
:email - send an Email instead. Must set email_target option.
:discard - don't send anything. May want to set discard_delay if simulating load

26
27
28
# File 'lib/sms_safe/config.rb', line 26

def intercept_mechanism
  @intercept_mechanism
end

#internal_phone_numbersObject

List of phone numbers that can accept SMS. Any phone number not on this list will get the SMS intercepted Leaving this empty means all SMS are intercepted, which is a valid use case. Value can be a String, a Regex, or a Proc to determine whether the phone is internal or not. Value can also be an Array, in which case the SMS will be allowed to go through if any of the entries match.


19
20
21
# File 'lib/sms_safe/config.rb', line 19

def internal_phone_numbers
  @internal_phone_numbers
end

#redirect_targetObject

The target number where messages are redirected, if intercept mechanism is :redirect Value can be a string or a Proc that returns a string


30
31
32
# File 'lib/sms_safe/config.rb', line 30

def redirect_target
  @redirect_target
end