Class: ShopifyAPIRetry::Request
- Inherits:
-
Object
- Object
- ShopifyAPIRetry::Request
- Defined in:
- lib/shopify_api_retry.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cfg = nil) ⇒ Request
constructor
A new instance of Request.
- #retry(&block) ⇒ Object
Constructor Details
#initialize(cfg = nil) ⇒ Request
Returns a new instance of Request.
97 98 99 |
# File 'lib/shopify_api_retry.rb', line 97 def initialize(cfg = nil) @handlers = ShopifyAPIRetry.config.merge(cfg) end |
Class Method Details
.retry(cfg = nil, &block) ⇒ Object
93 94 95 |
# File 'lib/shopify_api_retry.rb', line 93 def self.retry(cfg = nil, &block) new(cfg).retry(&block) end |
Instance Method Details
#retry(&block) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/shopify_api_retry.rb', line 101 def retry(&block) raise ArgumentError, "block required" unless block_given? begin result = request(&block) rescue => e handler = find_handler(e) raise unless handler && snooze(handler) retry end result end |