Class: Jiralicious::Issue::Comment
- Defined in:
- lib/jiralicious/issue/comment.rb
Overview
The Comment class retrieves and controls the functionality of Comments associated with an Issue.
Instance Attribute Summary collapse
-
#jira_key ⇒ Object
Related Issue Key.
Attributes inherited from Base
Class Method Summary collapse
-
.add(comment, key) ⇒ Object
Adds a new Comment to the Issue.
-
.edit(comment, key, id) ⇒ Object
Updates a Comment based on Issue Key and Comment ID.
-
.find_by_key(key) ⇒ Object
Retrieves the Comments based on the Issue Key.
-
.find_by_key_and_id(key, id) ⇒ Object
Retrieves the Comment based on the Issue Key and Comment ID.
-
.remove(key, id) ⇒ Object
Removes/Deletes the Comment from the Jira Issue.
Instance Method Summary collapse
-
#add(comment) ⇒ Object
Adds a new Comment to the loaded Issue.
-
#edit(comment) ⇒ Object
Updates a Comment based on loaded Issue and Comment .
-
#find_by_id(id) ⇒ Object
Retrieves the Comment based on the loaded Issue and Comment ID.
-
#initialize(decoded_json = nil) ⇒ Comment
constructor
Initialization Method.
-
#remove(id = self.id) ⇒ Object
Removes/Deletes the Comment from the Jira Issue.
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find, find_all, handler, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash, #reload
Methods included from Parsers::FieldParser
Constructor Details
#initialize(decoded_json = nil) ⇒ Comment
Initialization Method
- Arguments
-
:decoded_json (optional) rubyized json object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jiralicious/issue/comment.rb', line 18 def initialize(decoded_json = nil) if (decoded_json != nil) properties_from_hash(decoded_json) super(decoded_json) parse!(decoded_json) if self.respond_to?("comments") if self.comments.is_a? Array a = {} self.comments.each do |comment| a["_#{comment['id']}"] = Comment.new(comment) end self.comments = a end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jiralicious::Base
Instance Attribute Details
#jira_key ⇒ Object
Related Issue Key
10 11 12 |
# File 'lib/jiralicious/issue/comment.rb', line 10 def jira_key @jira_key end |
Class Method Details
.add(comment, key) ⇒ Object
Adds a new Comment to the Issue
- Arguments
-
:comment (required) comment to post
:key (required) issue key
72 73 74 |
# File 'lib/jiralicious/issue/comment.rb', line 72 def add(comment, key) fetch({:method => :post, :body => comment, :parent => parent_name, :parent_key => key}) end |
.edit(comment, key, id) ⇒ Object
Updates a Comment based on Issue Key and Comment ID
- Arguments
-
:comment (required) comment to post
:key (required) issue key
:id (required) comment id
86 87 88 |
# File 'lib/jiralicious/issue/comment.rb', line 86 def edit(comment, key, id) fetch({:method => :put, :key => id, :body => comment, :parent => parent_name, :parent_key => key}) end |
.find_by_key(key) ⇒ Object
Retrieves the Comments based on the Issue Key
- Arguments
-
:key (required) issue key
42 43 44 45 46 47 |
# File 'lib/jiralicious/issue/comment.rb', line 42 def find_by_key(key) response = fetch({:parent => parent_name, :parent_key => key}) a = new(response) a.jira_key = key return a end |
.find_by_key_and_id(key, id) ⇒ Object
Retrieves the Comment based on the Issue Key and Comment ID
- Arguments
-
:key (required) issue key
:id (required) comment id
57 58 59 60 61 62 |
# File 'lib/jiralicious/issue/comment.rb', line 57 def find_by_key_and_id(key, id) response = fetch({:parent => parent_name, :parent_key => key, :key => id}) a = new(response) a.jira_key = key return a end |
.remove(key, id) ⇒ Object
Removes/Deletes the Comment from the Jira Issue. It is not recommended to delete comments however the functionality is provided. It is recommended to override this function to throw an error or warning to maintain data integrity in systems that do not allow deleting from a remote location.
- Arguments
-
:key (required) issue key
:id (required) comment id
102 103 104 |
# File 'lib/jiralicious/issue/comment.rb', line 102 def remove(key, id) fetch({:method => :delete, :body_to_params => true, :key => id, :parent => parent_name, :parent_key => key}) end |
Instance Method Details
#add(comment) ⇒ Object
Adds a new Comment to the loaded Issue
- Arguments
-
:comment (required) comment text
123 124 125 |
# File 'lib/jiralicious/issue/comment.rb', line 123 def add(comment) self.class.add(comment, @jira_key) end |
#edit(comment) ⇒ Object
Updates a Comment based on loaded Issue and Comment
- Arguments
-
:comment (required) comment text
133 134 135 |
# File 'lib/jiralicious/issue/comment.rb', line 133 def edit(comment) self.class.edit(comment, @jira_key, self.id) end |
#find_by_id(id) ⇒ Object
Retrieves the Comment based on the loaded Issue and Comment ID
- Arguments
-
:id (required) comment id
113 114 115 |
# File 'lib/jiralicious/issue/comment.rb', line 113 def find_by_id(id) self.class.find_by_key_and_id(@jira_key, id) end |
#remove(id = self.id) ⇒ Object
Removes/Deletes the Comment from the Jira Issue. It is not recommended to delete comments. However, the functionality is provided. It is recommended to override this function to throw an error or warning to maintain data integrity in systems that do not allow deleting from a remote location.
- Arguments
-
:id (optional) comment id
147 148 149 |
# File 'lib/jiralicious/issue/comment.rb', line 147 def remove(id = self.id) self.class.remove(@jira_key, id) end |