Class: Dynectastic::Request
- Inherits:
-
Object
- Object
- Dynectastic::Request
- Includes:
- HTTParty
- Defined in:
- lib/dynectastic/request.rb
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
debug_output $stdout.
-
#job_id ⇒ Object
readonly
debug_output $stdout.
-
#job_incomplete ⇒ Object
readonly
debug_output $stdout.
-
#resource ⇒ Object
readonly
debug_output $stdout.
-
#response ⇒ Object
readonly
debug_output $stdout.
Instance Method Summary collapse
-
#initialize(resource) ⇒ Request
constructor
A new instance of Request.
- #job ⇒ Object
- #perform(*args) ⇒ Object
Constructor Details
#initialize(resource) ⇒ Request
Returns a new instance of Request.
13 14 15 |
# File 'lib/dynectastic/request.rb', line 13 def initialize(resource) @resource = resource end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
debug_output $stdout
11 12 13 |
# File 'lib/dynectastic/request.rb', line 11 def attempts @attempts end |
#job_id ⇒ Object (readonly)
debug_output $stdout
11 12 13 |
# File 'lib/dynectastic/request.rb', line 11 def job_id @job_id end |
#job_incomplete ⇒ Object (readonly)
debug_output $stdout
11 12 13 |
# File 'lib/dynectastic/request.rb', line 11 def job_incomplete @job_incomplete end |
#resource ⇒ Object (readonly)
debug_output $stdout
11 12 13 |
# File 'lib/dynectastic/request.rb', line 11 def resource @resource end |
#response ⇒ Object (readonly)
debug_output $stdout
11 12 13 |
# File 'lib/dynectastic/request.rb', line 11 def response @response end |
Instance Method Details
#job ⇒ Object
17 18 19 20 21 |
# File 'lib/dynectastic/request.rb', line 17 def job if job_id Job.new(self) end end |
#perform(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dynectastic/request.rb', line 23 def perform(*args) method, path, = args.shift, args.shift, args.last ||= {} () reset_attempts begin process_response(self.class.send(method, path, )) rescue HTTParty::RedirectionTooDeep => e if e.response['Location'].include?("/REST/Job") memorize_response_data(e.response) false else raise e end rescue SessionBusy => e if attempts_left? sleep(10) increment_attempts retry else raise e end end end |