Sha256: 1e00b348db0f049805fe8d4651ea97b6205cff3e072a86eed150fc1dace960d8

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

module Octokit
  class Client
    module Request
      def get(path, options={}, raw=false, format_path=true, authenticate=true)
        request(:get, path, options, raw, format_path, authenticate)
      end

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

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

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

      private

      def request(method, path, options, raw, format_path, authenticate)
        response = connection(raw, authenticate).send(method) do |request|
          path = formatted_path(path) if format_path
          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

      def formatted_path(path)
        ['api', ['v', version].join, format, path].compact.join('/')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
octokit-0.6.2 lib/octokit/client/request.rb
hybridgroup-octokit-0.6.3 lib/octokit/client/request.rb
hybridgroup-octokit-0.6.2 lib/octokit/client/request.rb
hybridgroup-octokit-0.6.1 lib/octokit/client/request.rb
xn-octokit-0.6.1 lib/octokit/client/request.rb
octokit-0.6.1 lib/octokit/client/request.rb
octokit-0.6.0 lib/octokit/client/request.rb
octokit-0.5.2 lib/octokit/client/request.rb
octokit-0.5.1 lib/octokit/client/request.rb
octokit-0.5.0 lib/octokit/client/request.rb