Class: TrackerApi::Resources::Comment
- Includes:
- Shared::Base
- Defined in:
- lib/tracker_api/resources/comment.rb
Defined Under Namespace
Classes: UpdateRepresenter
Instance Method Summary collapse
-
#attachments(reload: false) ⇒ Array[FileAttachments]
Provides a list of all the attachments on the comment.
-
#create_attachments(params) ⇒ Comment
Newly created Comment.
- #delete ⇒ Object
- #delete_attachments(attachment_ids = nil) ⇒ Object
- #save ⇒ Object
Methods included from Shared::Base
Instance Method Details
#attachments(reload: false) ⇒ Array[FileAttachments]
Provides a list of all the attachments on the comment.
62 63 64 65 66 67 68 |
# File 'lib/tracker_api/resources/comment.rb', line 62 def (reload: false) if !reload && @file_attachments.present? @file_attachments else @file_attachments = Endpoints::Attachment.new(client).get(self) end end |
#create_attachments(params) ⇒ Comment
Returns newly created Comment.
48 49 50 51 |
# File 'lib/tracker_api/resources/comment.rb', line 48 def (params) self. = Endpoints::Attachments.new(client).create(self, params[:files]).collect(&:id) save end |
#delete ⇒ Object
40 41 42 43 44 |
# File 'lib/tracker_api/resources/comment.rb', line 40 def delete raise ArgumentError, 'Cannot delete a comment with an unknown story_id or epic_id.' if story_id.nil? && epic_id.nil? Endpoints::Comment.new(client).delete(self) end |
#delete_attachments(attachment_ids = nil) ⇒ Object
53 54 55 56 |
# File 'lib/tracker_api/resources/comment.rb', line 53 def ( = nil) self. = || .collect(&:id) save end |
#save ⇒ Object
34 35 36 37 38 |
# File 'lib/tracker_api/resources/comment.rb', line 34 def save raise ArgumentError, 'Cannot update a comment with an unknown story_id or epic_id.' if story_id.nil? && epic_id.nil? Endpoints::Comment.new(client).update(self, UpdateRepresenter.new(Comment.new(self.dirty_attributes))) end |