Class: Ghub::Endpoints::Repositories::Path
- Inherits:
-
Object
- Object
- Ghub::Endpoints::Repositories::Path
- Defined in:
- lib/ghub/endpoints/repositories/path.rb
Overview
Dynamically builds API repository path sfor users or organizations.
Constant Summary collapse
- KINDS =
%w[users orgs].freeze
Instance Method Summary collapse
- #create(kind, owner: nil) ⇒ Object
- #destroy ⇒ Object
- #index(kind, owner) ⇒ Object
-
#initialize(kinds: KINDS) ⇒ Path
constructor
A new instance of Path.
- #patch ⇒ Object
- #show ⇒ Object
Constructor Details
Instance Method Details
#create(kind, owner: nil) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ghub/endpoints/repositories/path.rb', line 27 def create kind, owner: nil case kind.to_s when "users" then Success "user/repos" when "orgs" owner ? Success("orgs/#{owner}/repos") : Failure("Organization name is missing.") else error kind end end |
#destroy ⇒ Object
38 |
# File 'lib/ghub/endpoints/repositories/path.rb', line 38 def destroy(...) = resource(...) |
#index(kind, owner) ⇒ Object
21 22 23 |
# File 'lib/ghub/endpoints/repositories/path.rb', line 21 def index kind, owner kinds.include?(kind.to_s) ? Success("#{kind}/#{owner}/repos") : error(kind) end |
#patch ⇒ Object
36 |
# File 'lib/ghub/endpoints/repositories/path.rb', line 36 def patch(...) = resource(...) |
#show ⇒ Object
25 |
# File 'lib/ghub/endpoints/repositories/path.rb', line 25 def show(...) = resource(...) |