Sha256: 1a14d679d44faf8a4ea02d4a3249bb1ec265d9d6ce6a76b903ac2efdfdb33f1c

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

module Recalls
  class Client
    module Request
      def get(path, options={}, raw=false)
        request(:get, path, options, raw)
      end

      def post(path, options={}, raw=false)
        request(:post, path, options, raw)
      end

      def put(path, options={}, raw=false)
        request(:put, path, options, raw)
      end

      def delete(path, options={}, raw=false)
        request(:delete, path, options, raw)
      end

      private

      def request(method, path, options, raw)
        response = connection(raw).send(method) do |request|
          case method
          when :get, :delete
            request.url(path, options)
          when :post, :put
            request.path = path
            request.body = options unless options.empty?
          end
        end
        raw ? response : response.body
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
recalls-0.1 lib/recalls/client/request.rb
Recalls-0.1 lib/recalls/client/request.rb