Class: ResqueKalashnikov::HttpRequest
- Inherits:
-
Object
- Object
- ResqueKalashnikov::HttpRequest
- Defined in:
- lib/resque_kalashnikov/http_request.rb
Instance Attribute Summary collapse
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#handle(http) ⇒ Object
This method is invoked inside EM no blocking calls, please.
-
#initialize(*args) ⇒ HttpRequest
constructor
A new instance of HttpRequest.
- #perform ⇒ Object
- #reload_opts ⇒ Object
- #retry_limit ⇒ Object
Constructor Details
#initialize(*args) ⇒ HttpRequest
Returns a new instance of HttpRequest.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/resque_kalashnikov/http_request.rb', line 7 def initialize(*args) case args.size when 1 then @url = args[0] when 2 then @url, @opts = args when 3 then @url, @http_method, @opts = args else raise "insufficient params in #{self.class}: args=#{args}" end @http_method ||= 'get' @opts ||= {} @http_method.downcase! end |
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
5 6 7 |
# File 'lib/resque_kalashnikov/http_request.rb', line 5 def http_method @http_method end |
#opts ⇒ Object
Returns the value of attribute opts.
5 6 7 |
# File 'lib/resque_kalashnikov/http_request.rb', line 5 def opts @opts end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/resque_kalashnikov/http_request.rb', line 5 def url @url end |
Class Method Details
.perform(*args) ⇒ Object
59 60 61 |
# File 'lib/resque_kalashnikov/http_request.rb', line 59 def perform(*args) new(*args).perform end |
Instance Method Details
#handle(http) ⇒ Object
This method is invoked inside EM no blocking calls, please
22 23 24 |
# File 'lib/resque_kalashnikov/http_request.rb', line 22 def handle http Resque::Catridge.new(self, http) end |
#perform ⇒ Object
30 31 32 33 34 |
# File 'lib/resque_kalashnikov/http_request.rb', line 30 def perform catrige = handle http_request reload if catrige.reload? && catrige.retries < retry_limit http_request.response end |
#reload_opts ⇒ Object
36 37 38 |
# File 'lib/resque_kalashnikov/http_request.rb', line 36 def reload_opts opts end |
#retry_limit ⇒ Object
26 27 28 |
# File 'lib/resque_kalashnikov/http_request.rb', line 26 def retry_limit instance_variable_get(:@retry_limit) || 2 end |