Provide an easy way to write attribute with defined? pattern
We have a number of methods look like this:
def access_token
return @access_token if defined?(@access_token)
@access_token = find_oauth_access_token || find_personal_access_token
end
It's violating https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12800 but I think that's fine. We could extend the cop so that it could allow this, but we could also just provide an easy way to write this so that the cop would be happy with it.
Maybe like this:
def access_token
fetch_ivar(:@access_token) do
find_oauth_access_token || find_personal_access_token
end
end
Provided in a module.
Edited by Lin Jen-Shin