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_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
- #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
46 47 48 |
# File 'lib/bitbucket_server/representation/comment.rb', line 46 def ['emailAddress'] end |
#author_username ⇒ Object
40 41 42 43 44 |
# File 'lib/bitbucket_server/representation/comment.rb', line 40 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.
75 76 77 |
# File 'lib/bitbucket_server/representation/comment.rb', line 75 def comments @comments ||= flatten_comments end |
#created_at ⇒ Object
54 55 56 |
# File 'lib/bitbucket_server/representation/comment.rb', line 54 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
50 51 52 |
# File 'lib/bitbucket_server/representation/comment.rb', line 50 def note raw_comment['text'] end |
#updated_at ⇒ Object
58 59 60 |
# File 'lib/bitbucket_server/representation/comment.rb', line 58 def updated_at self.class.(created_date) end |