Class: Ferryman::Dispatcher
- Inherits:
-
Object
- Object
- Ferryman::Dispatcher
- Defined in:
- lib/ferryman.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #deliver(phone_number, *args) ⇒ Object
-
#initialize ⇒ Dispatcher
constructor
A new instance of Dispatcher.
Constructor Details
#initialize ⇒ Dispatcher
Returns a new instance of Dispatcher.
113 114 115 |
# File 'lib/ferryman.rb', line 113 def initialize @config = Config.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
111 112 113 |
# File 'lib/ferryman.rb', line 111 def config @config end |
Instance Method Details
#deliver(phone_number, *args) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/ferryman.rb', line 117 def deliver(phone_number, *args) @config.rules.each do |rule| next unless rule.accept?(phone_number) rule.providers.each do |provider_name| provider = @config.providers[provider_name] params = [phone_number] + args begin return provider.call(*params) rescue DeliveryError next end end end nil end |