Class: Digto::Session
- Inherits:
-
Object
- Object
- Digto::Session
- Defined in:
- lib/digto.rb
Overview
Session
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, res) ⇒ Session
constructor
A new instance of Session.
- #response(status = 200, headers = {}, body = nil) ⇒ Object
Constructor Details
#initialize(url, res) ⇒ Session
Returns a new instance of Session.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/digto.rb', line 30 def initialize(url, res) @url = res.headers['Digto-URL'] @method = res.headers['Digto-Method'] @headers = res.headers @body = res.body @api_url = url @res = res @done = false end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
28 29 30 |
# File 'lib/digto.rb', line 28 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
28 29 30 |
# File 'lib/digto.rb', line 28 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
28 29 30 |
# File 'lib/digto.rb', line 28 def method @method end |
#url ⇒ Object
Returns the value of attribute url.
28 29 30 |
# File 'lib/digto.rb', line 28 def url @url end |
Instance Method Details
#response(status = 200, headers = {}, body = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/digto.rb', line 41 def response(status = 200, headers = {}, body = nil) raise 'already sent response' if @done @done = true headers['Digto-ID'] = @res.headers['Digto-ID'] headers['Digto-Status'] = status res = HTTP.headers(headers).post(@api_url, body) Digto.check_res_err(res) res end |