Module: FaradayCage::Helpers

Defined in:
lib/faraday_cage/helpers.rb

Instance Method Summary collapse

Instance Method Details

#basic_auth(login, pass = nil) ⇒ Object



26
27
28
# File 'lib/faraday_cage/helpers.rb', line 26

def basic_auth(, pass = nil)
  FaradayCage.connection.basic_auth(, pass)
end

#bodyObject



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_responseObject



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_headersObject



38
39
40
# File 'lib/faraday_cage/helpers.rb', line 38

def response_headers
  last_response.headers
end

#sourceObject



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(, options = nil)
  FaradayCage.connection.token_auth(token, options)
end