Sha256: 53449e28849871e3dec5682f23fa8e094ca9d1f76d6e20dc6709070cfa459d00

Contents?: true

Size: 576 Bytes

Versions: 8

Compression:

Stored size: 576 Bytes

Contents

require 'json'

module CassetteRack
  module Decorator
    class Response
      def initialize(response)
        @response = response
      end

      def to_liquid
        {
          'status_code' => status_code,
          'status_message' => status_message,
          'body' => body,
        }
      end

      def status_code
        @response.status.code
      end

      def status_message
        @response.status.message
      end

      def body
        JSON.pretty_generate JSON.parse(@response.body)
      rescue
        @response.body
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cassette-rack-0.10.0 lib/cassette-rack/decorator/response.rb
cassette-rack-0.9.0 lib/cassette-rack/decorator/response.rb
cassette-rack-0.8.1 lib/cassette-rack/decorator/response.rb
cassette-rack-0.8.0 lib/cassette-rack/decorator/response.rb
cassette-rack-0.7.0 lib/cassette-rack/decorator/response.rb
cassette-rack-0.6.0 lib/cassette-rack/decorator/response.rb
cassette-rack-0.5.0 lib/cassette-rack/decorator/response.rb
cassette-rack-0.4.1 lib/cassette-rack/decorator/response.rb