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, #options

Instance Method Summary collapse

Methods inherited from Wrapper

[], #[], #frontend, #frontend=, #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.



4
5
6
# File 'lib/gh/custom_limit.rb', line 4

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



4
5
6
# File 'lib/gh/custom_limit.rb', line 4

def client_secret
  @client_secret
end

Instance Method Details

#full_url(key) ⇒ Object



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

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



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

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