class Endpointer::ResponsePresenter

Public Instance Methods

present(status: , body: , headers: , request_body: , resource: ) click to toggle source
# File lib/endpointer/response_presenter.rb, line 5
def present(status: , body: , headers: , request_body: , resource: )
  Response.new(
    status,
    substituted_body(request_body, body, resource),
    sanitise_headers(uglify_headers(headers))
  )
end

Private Instance Methods

sanitise_headers(headers) click to toggle source
# File lib/endpointer/response_presenter.rb, line 22
def sanitise_headers(headers)
  headers.reject {|header, _|
    header.match(/TRANSFER-ENCODING/)
  }
end
substituted_body(request_body, response_body, resource) click to toggle source
# File lib/endpointer/response_presenter.rb, line 28
def substituted_body(request_body, response_body, resource)
  Endpointer::ResponseSubstitutioner.new.substitute(request_body, response_body, resource.substitutions)
end
uglify_headers(headers) click to toggle source
# File lib/endpointer/response_presenter.rb, line 15
def uglify_headers(headers)
  headers.inject({}) { |out, (key, value)|
    out[key.to_s.upcase.tr('_', '-')] = value
    out
  }
end