Sha256: 86567b94a0475e2a1f52d3891977dcf35c35b9ecb112667a69c632946776cd32

Contents?: true

Size: 538 Bytes

Versions: 6

Compression:

Stored size: 538 Bytes

Contents

module Alf
  module Rest
    class Payload
      module Client

        def payload
          JSON::load(last_response.body)
        end

        def to_payload(h)
          case c = headers["Content-Type"]
          when /urlencoded/ then URI.escape(h.map{|k,v| "#{k}=#{v}"}.join('&'))
          when /json/       then ::JSON.dump(body)
          else
            raise "Unable to generate payload for Content-Type `#{c}`"
          end
        end

      end # module Client
    end # class Payload
  end # module Rest
end # module Alf

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alf-rest-0.17.1 lib/alf/rest/payload/client.rb
alf-rest-0.16.3 lib/alf/rest/payload/client.rb
alf-rest-0.16.2 lib/alf/rest/payload/client.rb
alf-rest-0.16.1 lib/alf/rest/payload/client.rb
alf-rest-0.16.0 lib/alf/rest/payload/client.rb
alf-rest-0.14.0 lib/alf/rest/payload/client.rb