Sha256: f02b7e6878c9dca09f8cf58cce9cadcc019ae3c87671b3bcaf277cf829bd0287

Contents?: true

Size: 428 Bytes

Versions: 2

Compression:

Stored size: 428 Bytes

Contents

module JsonMatchers
  class Payload
    def initialize(payload)
      @payload = extract_json_string(payload)
    end

    def to_s
      payload
    end

    private

    attr_reader :payload

    def extract_json_string(payload)
      if payload.respond_to?(:body)
        payload.body
      elsif payload.is_a?(Array) || payload.is_a?(Hash)
        payload.to_json
      else
        payload.to_s
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
json_matchers-0.9.0 lib/json_matchers/payload.rb
json_matchers-0.8.0 lib/json_matchers/payload.rb