summaryrefslogtreecommitdiff
path: root/lib/bitbucket
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-11-11 16:08:03 -0800
committerStan Hu <stanhu@gmail.com>2016-11-21 16:47:28 -0800
commitb25ebfe67b0e5448e9625e7a5c469ab41a4b7059 (patch)
tree79f2fa87f3e1c21988ddfaf6ac45409a949a2f5a /lib/bitbucket
parent9860488360681a3b10c3de04606ef931c3639601 (diff)
downloadgitlab-ce-b25ebfe67b0e5448e9625e7a5c469ab41a4b7059.tar.gz
Lazily load Bitbucket connection
Diffstat (limited to 'lib/bitbucket')
-rw-r--r--lib/bitbucket/connection.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb
index 00f127f9507..e9cbf36a44b 100644
--- a/lib/bitbucket/connection.rb
+++ b/lib/bitbucket/connection.rb
@@ -13,13 +13,18 @@ module Bitbucket
@expires_at = options.fetch(:expires_at)
@expires_in = options.fetch(:expires_in)
@refresh_token = options.fetch(:refresh_token)
+ end
- @client = OAuth2::Client.new(provider.app_id, provider.app_secret, options)
- @connection = OAuth2::AccessToken.new(@client, @token, refresh_token: @refresh_token, expires_at: @expires_at, expires_in: @expires_in)
+ def client
+ @client ||= OAuth2::Client.new(provider.app_id, provider.app_secret, options)
+ end
+
+ def connection
+ @connection ||= OAuth2::AccessToken.new(client, @token, refresh_token: @refresh_token, expires_at: @expires_at, expires_in: @expires_in)
end
def query(params = {})
- @query.update(params)
+ @query.merge!(params)
end
def get(path, query = {})
@@ -46,7 +51,7 @@ module Bitbucket
private
- attr_reader :connection, :expires_at, :expires_in, :refresh_token, :token
+ attr_reader :expires_at, :expires_in, :refresh_token, :token
def build_url(path)
return path if path.starts_with?(root_url)