Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
3133bf050549
Commit
3133bf05
authored
Nov 11, 2016
by
Stan Hu
Browse files
Lazily load Bitbucket connection
parent
2a52f221b97a
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/bitbucket/connection.rb
View file @
3133bf05
...
...
@@ -13,4 +13,5 @@
@expires_at
=
options
.
fetch
(
:expires_at
)
@expires_in
=
options
.
fetch
(
:expires_in
)
@refresh_token
=
options
.
fetch
(
:refresh_token
)
end
...
...
@@ -16,6 +17,10 @@
@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
=
{})
...
...
@@ -19,7 +24,7 @@
end
def
query
(
params
=
{})
@query
.
update
(
params
)
@query
.
merge!
(
params
)
end
def
get
(
path
,
query
=
{})
...
...
@@ -46,7 +51,7 @@
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment