Sha256: 825f3f2075ecf421095a6663436742acebd8f3f332cf12586f3e594f95974a6b

Contents?: true

Size: 637 Bytes

Versions: 19

Compression:

Stored size: 637 Bytes

Contents

module GH
  # Adds Client info so even unauthenticated requests can use a custom request limit
  class CustomLimit < Wrapper
    attr_accessor :client_id, :client_secret

    def setup(backend, options)
      @client_id     = options[:client_id]
      @client_secret = options[:client_secret]
      super
    end

    def full_url(key)
      return super unless client_id

      url    = super
      params = url.query_values || {}

      unless params.include? 'client_id'
        params['client_id']     = client_id
        params['client_secret'] = client_secret
      end

      url.query_values = params
      url
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
gh-0.18.0 lib/gh/custom_limit.rb
gh-0.17.0 lib/gh/custom_limit.rb
gh-0.16.0 lib/gh/custom_limit.rb
gh-0.16.0.beta1 lib/gh/custom_limit.rb
gh-akerl-0.15.1.1 lib/gh/custom_limit.rb
gh-akerl-0.15.1 lib/gh/custom_limit.rb
gh-0.15.1 lib/gh/custom_limit.rb
gh-0.15.0 lib/gh/custom_limit.rb
gh-0.14.0 lib/gh/custom_limit.rb
gh-0.13.3 lib/gh/custom_limit.rb
gh-0.13.2 lib/gh/custom_limit.rb
gh-0.13.1 lib/gh/custom_limit.rb
gh-0.13.0 lib/gh/custom_limit.rb
gh-0.12.4 lib/gh/custom_limit.rb
gh-0.12.3 lib/gh/custom_limit.rb
gh-0.12.2 lib/gh/custom_limit.rb
gh-0.12.1 lib/gh/custom_limit.rb
gh-0.12.0 lib/gh/custom_limit.rb
gh-0.11.3 lib/gh/custom_limit.rb