Class: Cp8Cli::Github::PullRequest

Inherits:
Base
  • Object
show all
Defined in:
lib/cp8_cli/github/pull_request.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

configure

Constructor Details

#initialize(from:, to:, title: nil, body: nil) ⇒ PullRequest

Returns a new instance of PullRequest.



11
12
13
14
15
16
# File 'lib/cp8_cli/github/pull_request.rb', line 11

def initialize(from:, to:, title: nil, body: nil)
  @title = title
  @body = body
  @from = from
  @to = to
end

Class Method Details

.create(attributes = {}) ⇒ Object



7
8
9
# File 'lib/cp8_cli/github/pull_request.rb', line 7

def self.create(attributes = {})
  new(attributes).save
end

Instance Method Details

#open(expand: 1) ⇒ Object



18
19
20
21
22
23
# File 'lib/cp8_cli/github/pull_request.rb', line 18

def open(expand: 1)
  query = base_query.merge(expand: expand)
  url = "#{base_url}?#{query.compact.to_query}"

  Command.open_url(url)
end

#saveObject



25
26
27
28
29
30
31
32
33
# File 'lib/cp8_cli/github/pull_request.rb', line 25

def save
  client.create_pull_request(
    repo.shorthand,
    to,
    from,
    title,
    body
  )
end