Sha256: 7d99cb4355830cd882d2b613bd1fb7d95712c15f29fa663d22d2fb2a5f137975

Contents?: true

Size: 768 Bytes

Versions: 6

Compression:

Stored size: 768 Bytes

Contents

require 'active_support/inflector'

class HyperionResult
  attr_reader :route, :status, :code, :body

  # @param status [HyperionStatus]
  # @param code [Integer] the HTTP response code
  # @param body [Object, Hash<String,Object>] the deserialized response body.
  #   The type is determined by the content-type.
  #   JSON is deserialized to a Hash<String, Object>
  def initialize(route, status, code=nil, body=nil)
    @route, @status, @code, @body = route, status, code, body
  end

  def to_s
    if status == HyperionStatus::CHECK_CODE
      "HTTP #{code}: #{route.to_s}"
    elsif status == HyperionStatus::BAD_ROUTE
      "#{status.value.to_s.humanize} (#{code}): #{route.to_s}"
    else
      "#{status.value.to_s.humanize}: #{route.to_s}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyperion_http-0.1.7 lib/hyperion/types/hyperion_result.rb
hyperion_http-0.1.6 lib/hyperion/types/hyperion_result.rb
hyperion_http-0.1.5 lib/hyperion/types/hyperion_result.rb
hyperion_http-0.1.4 lib/hyperion/types/hyperion_result.rb
hyperion_http-0.1.3 lib/hyperion/types/hyperion_result.rb
hyperion_http-0.1.2 lib/hyperion/types/hyperion_result.rb