Module: FaradayCage::Helpers
- Defined in:
- lib/faraday_cage/helpers.rb
Instance Method Summary collapse
- #basic_auth(login, pass = nil) ⇒ Object
- #body ⇒ Object
- #header(name, value) ⇒ Object
- #headers(hash) ⇒ Object
- #last_response ⇒ Object
- #params(hash) ⇒ Object
- #reset_faraday_cage! ⇒ Object
- #response_headers ⇒ Object
- #source ⇒ Object
- #token_auth(login, options = nil) ⇒ Object
Instance Method Details
#basic_auth(login, pass = nil) ⇒ Object
26 27 28 |
# File 'lib/faraday_cage/helpers.rb', line 26 def basic_auth(login, pass = nil) FaradayCage.connection.basic_auth(login, pass) end |
#body ⇒ Object
42 43 44 |
# File 'lib/faraday_cage/helpers.rb', line 42 def body last_response.body end |
#header(name, value) ⇒ Object
22 23 24 |
# File 'lib/faraday_cage/helpers.rb', line 22 def header(name, value) FaradayCage.connection.headers[name] = value end |
#headers(hash) ⇒ Object
18 19 20 |
# File 'lib/faraday_cage/helpers.rb', line 18 def headers(hash) FaradayCage.connection.headers = hash end |
#last_response ⇒ Object
34 35 36 |
# File 'lib/faraday_cage/helpers.rb', line 34 def last_response @last_response || raise(FaradayCage::Error , 'No response yet. Request a page first.') end |
#params(hash) ⇒ Object
14 15 16 |
# File 'lib/faraday_cage/helpers.rb', line 14 def params(hash) FaradayCage.connection.params = hash end |
#reset_faraday_cage! ⇒ Object
50 51 52 53 |
# File 'lib/faraday_cage/helpers.rb', line 50 def reset_faraday_cage! FaradayCage.reset! @last_response = nil end |
#response_headers ⇒ Object
38 39 40 |
# File 'lib/faraday_cage/helpers.rb', line 38 def response_headers last_response.headers end |
#source ⇒ Object
46 47 48 |
# File 'lib/faraday_cage/helpers.rb', line 46 def source last_response.env[:raw_body] || last_response.body end |
#token_auth(login, options = nil) ⇒ Object
30 31 32 |
# File 'lib/faraday_cage/helpers.rb', line 30 def token_auth(login, = nil) FaradayCage.connection.token_auth(token, ) end |