Class: HornOfPlenty::Adapters::Github::Requests::ListPullRequests

Inherits:
Request
  • Object
show all
Defined in:
lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#query_class, #response_class

Constructor Details

#initialize(format: 'raw', pagination: {}, query: {}, repository:) ⇒ ListPullRequests

Returns a new instance of ListPullRequests.



14
15
16
17
18
19
20
21
22
23
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 14

def initialize(format:     'raw',
               pagination: {},
               query:      {},
               repository:)

  self.format     = format
  self.pagination = pagination
  self.query      = query
  self.repository = repository
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



9
10
11
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 9

def format
  @format
end

#paginationObject

Returns the value of attribute pagination.



9
10
11
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 9

def pagination
  @pagination
end

#queryObject

Returns the value of attribute query.



9
10
11
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 9

def query
  @query
end

#repositoryObject

Returns the value of attribute repository.



9
10
11
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 9

def repository
  @repository
end

Instance Method Details

#methodObject



25
26
27
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 25

def method
  'get'
end

#pathObject



29
30
31
32
33
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 29

def path
  return "repos/#{repository}/pulls" unless query[:id]

  "repos/#{repository}/pulls/#{query[:id]}"
end

#to_hObject Also known as: to_params



35
36
37
38
# File 'lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb', line 35

def to_h
  @to_h ||= query_class.new(query).to_h.
            merge(pagination_hash)
end