Class: BabySMS::Adapters::TestAdapter
- Inherits:
-
BabySMS::Adapter
- Object
- BabySMS::Adapter
- BabySMS::Adapters::TestAdapter
- Defined in:
- lib/babysms/adapters/test_adapter.rb
Defined Under Namespace
Classes: WebHook
Instance Attribute Summary collapse
-
#fails ⇒ Object
Returns the value of attribute fails.
-
#outbox ⇒ Object
Returns the value of attribute outbox.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Attributes inherited from BabySMS::Adapter
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(verbose: false, fails: false, from: '+1555-555-5555') ⇒ TestAdapter
constructor
A new instance of TestAdapter.
Methods inherited from BabySMS::Adapter
#adapter_id, adapter_name, #adapter_name, for_adapter_id, for_number, #web_hook, #web_hook?, #web_hook_class
Constructor Details
#initialize(verbose: false, fails: false, from: '+1555-555-5555') ⇒ TestAdapter
Returns a new instance of TestAdapter.
15 16 17 18 19 20 21 |
# File 'lib/babysms/adapters/test_adapter.rb', line 15 def initialize(verbose: false, fails: false, from: '+1555-555-5555') super(from: from) self.verbose = verbose self.fails = fails self.outbox = [] end |
Instance Attribute Details
#fails ⇒ Object
Returns the value of attribute fails.
12 13 14 |
# File 'lib/babysms/adapters/test_adapter.rb', line 12 def fails @fails end |
#outbox ⇒ Object
Returns the value of attribute outbox.
13 14 15 |
# File 'lib/babysms/adapters/test_adapter.rb', line 13 def outbox @outbox end |
#verbose ⇒ Object
Returns the value of attribute verbose.
11 12 13 |
# File 'lib/babysms/adapters/test_adapter.rb', line 11 def verbose @verbose end |
Instance Method Details
#deliver(message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/babysms/adapters/test_adapter.rb', line 23 def deliver() if fails raise BabySMS::FailedDelivery.new('intentional failure', adapter: self) end outbox.push() if verbose terminal_output = <<~"MSG" #{"SMS:".bright.yellow} -> #{.to.bright.yellow}: >> #{.contents.white} MSG $stderr.puts terminal_output end end |