Class: Gitlab::GithubImport::Representation::PullRequestReview

Inherits:
Object
  • Object
show all
Includes:
ExposeAttribute, ToHash
Defined in:
lib/gitlab/github_import/representation/pull_request_review.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ToHash

#convert_value_for_to_hash, #to_hash

Constructor Details

#initialize(attributes) ⇒ PullRequestReview

attributes - A Hash containing the raw note details. The keys of this

Hash must be Symbols.

39
40
41
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 39

def initialize(attributes)
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.


10
11
12
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 10

def attributes
  @attributes
end

Class Method Details

.from_api_response(review) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 14

def self.from_api_response(review)
  user = Representation::User.from_api_response(review.user) if review.user

  new(
    merge_request_id: review.merge_request_id,
    author: user,
    note: review.body,
    review_type: review.state,
    submitted_at: review.,
    review_id: review.id
  )
end

.from_json_hash(raw_hash) ⇒ Object

Builds a new note using a Hash that was built from a JSON payload.


28
29
30
31
32
33
34
35
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 28

def self.from_json_hash(raw_hash)
  hash = Representation.symbolize_hash(raw_hash)

  hash[:author] &&= Representation::User.from_json_hash(hash[:author])
  hash[:submitted_at] = Time.parse(hash[:submitted_at]).in_time_zone if hash[:submitted_at].present?

  new(hash)
end

Instance Method Details

#approval?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 43

def approval?
  review_type == 'APPROVED'
end

#github_identifiersObject


47
48
49
50
51
52
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 47

def github_identifiers
  {
    review_id: review_id,
    merge_request_id: merge_request_id
  }
end