Module: EventMachine::Smsified::ServerHandler
- Included in:
- Server
- Defined in:
- lib/em-smsified/server.rb
Overview
Does the actual handling of the incoming notifications from SMSified. Factored out to ease in testing.
Instance Method Summary collapse
-
#handle(method, content) ⇒ bool
Inspects the method and contents of the incoming request and handles it.
-
#on_delivery_notification(&blk) ⇒ Object
Sets the block to call when a delivery notification arrives.
-
#on_incoming_message(&blk) ⇒ Object
Sets the block to call when an incoming message arrives.
-
#on_unknown(&blk) ⇒ Object
Sets the block to call when an unknown message arrives.
- #trigger_on_delivery_notification(msg) ⇒ Object
- #trigger_on_incoming_message(msg) ⇒ Object
- #trigger_on_unknown(request) ⇒ Object
Instance Method Details
#handle(method, content) ⇒ bool
Inspects the method and contents of the incoming request and handles it.
46 47 48 49 50 51 |
# File 'lib/em-smsified/server.rb', line 46 def handle(method, content) if is_post? method return (content) || handle_delivery_notification(content) || handle_unknown(content) end return false end |
#on_delivery_notification(&blk) ⇒ Object
Sets the block to call when a delivery notification arrives
17 18 19 |
# File 'lib/em-smsified/server.rb', line 17 def on_delivery_notification(&blk) @on_delivery_notification = blk end |
#on_incoming_message(&blk) ⇒ Object
Sets the block to call when an incoming message arrives
10 11 12 |
# File 'lib/em-smsified/server.rb', line 10 def (&blk) = blk end |
#on_unknown(&blk) ⇒ Object
Sets the block to call when an unknown message arrives
24 25 26 |
# File 'lib/em-smsified/server.rb', line 24 def on_unknown(&blk) @on_unknown = blk end |
#trigger_on_delivery_notification(msg) ⇒ Object
32 33 34 |
# File 'lib/em-smsified/server.rb', line 32 def trigger_on_delivery_notification(msg) @on_delivery_notification.call(msg) if @on_delivery_notification end |
#trigger_on_incoming_message(msg) ⇒ Object
28 29 30 |
# File 'lib/em-smsified/server.rb', line 28 def (msg) .call(msg) if end |
#trigger_on_unknown(request) ⇒ Object
36 37 38 |
# File 'lib/em-smsified/server.rb', line 36 def trigger_on_unknown(request) @on_unknown.call(request) if @on_unknown end |