Class: Opener::CallbackHandler
- Inherits:
-
Object
- Object
- Opener::CallbackHandler
- Defined in:
- lib/opener/callback_handler.rb,
lib/opener/callback_handler/version.rb,
lib/opener/callback_handler/strategies/http.rb,
lib/opener/callback_handler/strategies/amazon_sqs.rb
Defined Under Namespace
Modules: Strategies
Constant Summary collapse
- STRATEGIES =
The available strategies. These are processed in order to make sure the order is correct (e.g. AmazonSqs should take precedence over Http).
[ Opener::CallbackHandler::Strategies::AmazonSqs, Opener::CallbackHandler::Strategies::Http, ]
- VERSION =
'1.1.0'
Instance Method Summary collapse
- #post(url, params = {}) ⇒ Object
-
#select_strategy(url) ⇒ Class
Returns the strategy class to use based on the input URL.
Instance Method Details
#post(url, params = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/opener/callback_handler.rb', line 27 def post(url, params = {}) strategy = select_strategy(url) unless strategy raise ArgumentError, "No strategy for URL #{url.inspect}" end strategy.new.process(url, params) end |
#select_strategy(url) ⇒ Class
Returns the strategy class to use based on the input URL.
43 44 45 46 47 |
# File 'lib/opener/callback_handler.rb', line 43 def select_strategy(url) return STRATEGIES.find do |const| const.pass_validation?(url) end end |