class Wrappi::CachedResponse

Public Class Methods

new(cached_data) click to toggle source

input is a <Response>.to_h Example input {

raw_body: '{"foo": "bar"}',
code: 200,
uri: "http://hello.com",
success: true

}

# File lib/wrappi/cached_response.rb, line 11
def initialize(cached_data)
  @cached_data = Fusu::HashWithIndifferentAccess.new(cached_data)
end

Public Instance Methods

body() click to toggle source
# File lib/wrappi/cached_response.rb, line 23
def body
  @body ||= JSON.parse(cached_data[:raw_body])
end
call() click to toggle source
# File lib/wrappi/cached_response.rb, line 15
def call
  self
end
called?() click to toggle source
# File lib/wrappi/cached_response.rb, line 19
def called?
  false
end
error?() click to toggle source
# File lib/wrappi/cached_response.rb, line 31
def error?
  !success?
end
raw_body() click to toggle source
# File lib/wrappi/cached_response.rb, line 35
def raw_body
  cached_data[:raw_body]
end
status() click to toggle source
# File lib/wrappi/cached_response.rb, line 43
def status
  cached_data[:code]
end
Also aliased as: status_code
status_code()
Alias for: status
success?() click to toggle source
# File lib/wrappi/cached_response.rb, line 27
def success?
  cached_data[:success]
end
uri() click to toggle source
# File lib/wrappi/cached_response.rb, line 39
def uri
  cached_data[:uri]
end

Private Instance Methods

cached_data() click to toggle source
# File lib/wrappi/cached_response.rb, line 50
def cached_data; @cached_data end