Sha256: 4bb901e984472d4bd3eeb620e7290fa9aaff7778ff576ae7e0981ecd485dc885

Contents?: true

Size: 480 Bytes

Versions: 4

Compression:

Stored size: 480 Bytes

Contents

module Smartdc
  class Response
    attr_reader :status, :headers, :body, :content

    def initialize(response)
      @status = response.status
      @headers = response.headers
      @body = response.body
      self.content = @body
    end

    def content=raw
      case raw
      when nil, ''
        @content = nil
      when 'true'
        @content = true
      when 'false'
        @content = false
      else
        @content = JSON.parse(raw)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smartdc-1.3.0 lib/smartdc/response.rb
smartdc-1.2.2 lib/smartdc/response.rb
smartdc-1.2.1 lib/smartdc/response.rb
smartdc-1.1.1 lib/smartdc/response.rb