Class: Ask::GitHub::ClientProxy
- Inherits:
-
BasicObject
- Defined in:
- lib/ask/github/client.rb
Overview
Proxies method calls to an Octokit::Client, converting
authentication errors into Ask::Auth::InvalidCredential, and
exposing the content helpers.
Constant Summary
collapse
- CONTENT_METHODS =
%i[default_branch tree file license].freeze
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ClientProxy.
104
105
106
107
|
# File 'lib/ask/github/client.rb', line 104
def initialize(client)
@client = client
@content = ::Ask::GitHub::Content.new(client)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
125
126
127
128
129
|
# File 'lib/ask/github/client.rb', line 125
def method_missing(name, ...)
@client.public_send(name, ...)
rescue ::Octokit::Unauthorized
::Kernel.raise ::Ask::Auth::InvalidCredential, :github_token
end
|
Instance Method Details
#default_branch(repo) ⇒ Object
109
110
111
|
# File 'lib/ask/github/client.rb', line 109
def default_branch(repo)
@content.default_branch(repo)
end
|
#file(repo, path, branch: nil) ⇒ Object
117
118
119
|
# File 'lib/ask/github/client.rb', line 117
def file(repo, path, branch: nil)
@content.file(repo, path, branch: branch)
end
|
#license(repo) ⇒ Object
121
122
123
|
# File 'lib/ask/github/client.rb', line 121
def license(repo)
@content.license(repo)
end
|
#respond_to?(name, include_private = false) ⇒ Boolean
BasicObject has no respond_to? — report the content helpers
explicitly, forward everything else to the wrapped client.
133
134
135
|
# File 'lib/ask/github/client.rb', line 133
def respond_to?(name, include_private = false)
CONTENT_METHODS.include?(name) || @client.respond_to?(name, include_private)
end
|
#tree(repo, branch: nil) ⇒ Object
113
114
115
|
# File 'lib/ask/github/client.rb', line 113
def tree(repo, branch: nil)
@content.tree(repo, branch: branch)
end
|