Class: Gitlab::GithubImport::Representation::PullRequestReview
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Representation::PullRequestReview
- Includes:
- ExposeAttribute, ToHash
- Defined in:
- lib/gitlab/github_import/representation/pull_request_review.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
-
.from_api_response(review, additional_data = {}) ⇒ Object
Builds a PullRequestReview from a GitHub API response.
-
.from_json_hash(raw_hash) ⇒ Object
Builds a new note using a Hash that was built from a JSON payload.
Instance Method Summary collapse
- #approval? ⇒ Boolean
- #github_identifiers ⇒ Object
-
#initialize(attributes) ⇒ PullRequestReview
constructor
attributes - A Hash containing the raw note details.
Methods included from ExposeAttribute
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.
43 44 45 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 43 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (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, additional_data = {}) ⇒ Object
Builds a PullRequestReview from a GitHub API response.
review - An instance of ‘Hash` containing the note details.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 17 def self.from_api_response(review, additional_data = {}) user = Representation::User.from_api_response(review[:user]) if review[:user] new( merge_request_id: review[:merge_request_id], merge_request_iid: review[:merge_request_iid], author: user, note: review[:body], review_type: review[:state], submitted_at: review[:submitted_at], 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.
32 33 34 35 36 37 38 39 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 32 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
47 48 49 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 47 def approval? review_type == 'APPROVED' end |
#github_identifiers ⇒ Object
51 52 53 54 55 56 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 51 def github_identifiers { merge_request_iid: merge_request_iid, review_id: review_id } end |