Class: Ghub::Endpoints::Repositories::Path

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(kinds: KINDS) ⇒ Path

Returns a new instance of Path.



17
18
19
# File 'lib/ghub/endpoints/repositories/path.rb', line 17

def initialize kinds: KINDS
  @kinds = kinds
end

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

#destroyObject



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

#patchObject



36
# File 'lib/ghub/endpoints/repositories/path.rb', line 36

def patch(...) = resource(...)

#showObject



25
# File 'lib/ghub/endpoints/repositories/path.rb', line 25

def show(...) = resource(...)