Class: GH::CustomLimit

Inherits:
Wrapper show all
Defined in:
lib/gh/custom_limit.rb

Overview

Adds Client info so even unauthenticated requests can use a custom request limit

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#backend, #frontend, #options

Instance Method Summary collapse

Methods inherited from Wrapper

#[], [], double_dispatch, #generate_response, #initialize, #inspect, #load, #prefixed, #reset, wraps

Constructor Details

This class inherits a constructor from GH::Wrapper

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



6
7
8
# File 'lib/gh/custom_limit.rb', line 6

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



6
7
8
# File 'lib/gh/custom_limit.rb', line 6

def client_secret
  @client_secret
end

Instance Method Details

#full_url(key) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gh/custom_limit.rb', line 14

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

#setup(backend, options) ⇒ Object



8
9
10
11
12
# File 'lib/gh/custom_limit.rb', line 8

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