Class: BitbucketServer::Representation::Comment
- Defined in:
- lib/bitbucket_server/representation/comment.rb
Overview
A general comment with the structure: “comment”: {
"author": {
"active": true,
"displayName": "root",
"emailAddress": "[email protected]",
"id": 1,
"links": {
"self": [
{
"href": "http://localhost:7990/users/root"
}
]
},
"name": "root",
"slug": "root",
"type": "NORMAL"
}
}
}
Direct Known Subclasses
Defined Under Namespace
Classes: CommentNode
Instance Attribute Summary collapse
-
#parent_comment ⇒ Object
readonly
Returns the value of attribute parent_comment.
Attributes inherited from Base
Instance Method Summary collapse
- #author_email ⇒ Object
- #author_name ⇒ Object
- #author_username ⇒ Object
-
#comments ⇒ Object
Bitbucket Server supports the ability to reply to any comment and created multiple threads.
- #created_at ⇒ Object
- #id ⇒ Object
-
#initialize(raw, parent_comment: nil) ⇒ Comment
constructor
A new instance of Comment.
- #note ⇒ Object
- #to_hash ⇒ Object
- #updated_at ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(raw, parent_comment: nil) ⇒ Comment
Returns a new instance of Comment.
30 31 32 33 34 |
# File 'lib/bitbucket_server/representation/comment.rb', line 30 def initialize(raw, parent_comment: nil) super(raw) @parent_comment = parent_comment end |
Instance Attribute Details
#parent_comment ⇒ Object (readonly)
Returns the value of attribute parent_comment.
26 27 28 |
# File 'lib/bitbucket_server/representation/comment.rb', line 26 def parent_comment @parent_comment end |
Instance Method Details
#author_email ⇒ Object
50 51 52 |
# File 'lib/bitbucket_server/representation/comment.rb', line 50 def ['emailAddress'] end |
#author_name ⇒ Object
40 41 42 |
# File 'lib/bitbucket_server/representation/comment.rb', line 40 def ['displayName'] end |
#author_username ⇒ Object
44 45 46 47 48 |
# File 'lib/bitbucket_server/representation/comment.rb', line 44 def ['username'] || ['slug'] || ['displayName'] end |
#comments ⇒ Object
Bitbucket Server supports the ability to reply to any comment and created multiple threads. It represents these as a linked list of comments within comments. For example:
“comments”: [
{
"author" : ...
"comments": [
{
"author": ...
Since GitLab only supports a single thread, we flatten all these comments into a single discussion.
79 80 81 |
# File 'lib/bitbucket_server/representation/comment.rb', line 79 def comments @comments ||= flatten_comments end |
#created_at ⇒ Object
58 59 60 |
# File 'lib/bitbucket_server/representation/comment.rb', line 58 def created_at self.class.(created_date) end |
#id ⇒ Object
36 37 38 |
# File 'lib/bitbucket_server/representation/comment.rb', line 36 def id raw_comment['id'] end |
#note ⇒ Object
54 55 56 |
# File 'lib/bitbucket_server/representation/comment.rb', line 54 def note raw_comment['text'] end |
#to_hash ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/bitbucket_server/representation/comment.rb', line 83 def to_hash parent_comment_note = parent_comment.note if parent_comment { id: id, author_name: , author_email: , author_username: , note: note, created_at: created_at, updated_at: updated_at, comments: comments.map(&:to_hash), parent_comment_note: parent_comment_note } end |
#updated_at ⇒ Object
62 63 64 |
# File 'lib/bitbucket_server/representation/comment.rb', line 62 def updated_at self.class.(created_date) end |