Class: Trello::Comment
Overview
A Comment is a string with a creation date; it resides inside a Card and belongs to a User.
Instance Attribute Summary collapse
- #action_id ⇒ String readonly
- #date ⇒ Datetime readonly
- #member_creator_id ⇒ String readonly
- #text ⇒ String readonly
Attributes inherited from BasicData
Class Method Summary collapse
-
.find(action_id) ⇒ Object
Locate a specific action and return a new Comment object.
Instance Method Summary collapse
-
#board ⇒ Object
Returns the board this comment is located.
-
#card ⇒ Object
Returns the card the comment is located.
-
#delete ⇒ Object
Deletes the comment from the card.
-
#list ⇒ Object
Returns the list the comment is located.
-
#update_fields(fields) ⇒ Object
Update the attributes of a Comment.
Methods inherited from BasicData
#==, client, create, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save
Methods included from JsonUtils
Constructor Details
This class inherits a constructor from Trello::BasicData
Instance Attribute Details
#action_id ⇒ String (readonly)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/trello/comment.rb', line 12 class Comment < BasicData register_attributes :action_id, :text, :date, :member_creator_id, readonly: [ :action_id, :text, :date, :member_creator_id ] validates_presence_of :action_id, :text, :date, :member_creator_id validates_length_of :text, in: 1..16384 class << self # Locate a specific action and return a new Comment object. def find(action_id) client.find(:action, action_id, filter: commentCard) end end # Update the attributes of a Comment # # Supply a hash of string keyed data retrieved from the Trello API representing # a Comment. def update_fields(fields) attributes[:action_id] = fields['id'] || attributes[:action_id] attributes[:text] = fields['data']['text'] || attributes[:text] attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date') attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id] self end # Returns the board this comment is located def board Board.from_response client.get("/actions/#{action_id}/board") end # Returns the card the comment is located def card Card.from_response client.get("/actions/#{action_id}/card") end # Returns the list the comment is located def list List.from_response client.get("/actions/#{action_id}/list") end # Deletes the comment from the card def delete ruta = "/actions/#{action_id}" client.delete(ruta) end # Returns the member who created the comment. one :member_creator, via: Member, path: :members, using: :member_creator_id end |
#date ⇒ Datetime (readonly)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/trello/comment.rb', line 12 class Comment < BasicData register_attributes :action_id, :text, :date, :member_creator_id, readonly: [ :action_id, :text, :date, :member_creator_id ] validates_presence_of :action_id, :text, :date, :member_creator_id validates_length_of :text, in: 1..16384 class << self # Locate a specific action and return a new Comment object. def find(action_id) client.find(:action, action_id, filter: commentCard) end end # Update the attributes of a Comment # # Supply a hash of string keyed data retrieved from the Trello API representing # a Comment. def update_fields(fields) attributes[:action_id] = fields['id'] || attributes[:action_id] attributes[:text] = fields['data']['text'] || attributes[:text] attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date') attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id] self end # Returns the board this comment is located def board Board.from_response client.get("/actions/#{action_id}/board") end # Returns the card the comment is located def card Card.from_response client.get("/actions/#{action_id}/card") end # Returns the list the comment is located def list List.from_response client.get("/actions/#{action_id}/list") end # Deletes the comment from the card def delete ruta = "/actions/#{action_id}" client.delete(ruta) end # Returns the member who created the comment. one :member_creator, via: Member, path: :members, using: :member_creator_id end |
#member_creator_id ⇒ String (readonly)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/trello/comment.rb', line 12 class Comment < BasicData register_attributes :action_id, :text, :date, :member_creator_id, readonly: [ :action_id, :text, :date, :member_creator_id ] validates_presence_of :action_id, :text, :date, :member_creator_id validates_length_of :text, in: 1..16384 class << self # Locate a specific action and return a new Comment object. def find(action_id) client.find(:action, action_id, filter: commentCard) end end # Update the attributes of a Comment # # Supply a hash of string keyed data retrieved from the Trello API representing # a Comment. def update_fields(fields) attributes[:action_id] = fields['id'] || attributes[:action_id] attributes[:text] = fields['data']['text'] || attributes[:text] attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date') attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id] self end # Returns the board this comment is located def board Board.from_response client.get("/actions/#{action_id}/board") end # Returns the card the comment is located def card Card.from_response client.get("/actions/#{action_id}/card") end # Returns the list the comment is located def list List.from_response client.get("/actions/#{action_id}/list") end # Deletes the comment from the card def delete ruta = "/actions/#{action_id}" client.delete(ruta) end # Returns the member who created the comment. one :member_creator, via: Member, path: :members, using: :member_creator_id end |
#text ⇒ String (readonly)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/trello/comment.rb', line 12 class Comment < BasicData register_attributes :action_id, :text, :date, :member_creator_id, readonly: [ :action_id, :text, :date, :member_creator_id ] validates_presence_of :action_id, :text, :date, :member_creator_id validates_length_of :text, in: 1..16384 class << self # Locate a specific action and return a new Comment object. def find(action_id) client.find(:action, action_id, filter: commentCard) end end # Update the attributes of a Comment # # Supply a hash of string keyed data retrieved from the Trello API representing # a Comment. def update_fields(fields) attributes[:action_id] = fields['id'] || attributes[:action_id] attributes[:text] = fields['data']['text'] || attributes[:text] attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date') attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id] self end # Returns the board this comment is located def board Board.from_response client.get("/actions/#{action_id}/board") end # Returns the card the comment is located def card Card.from_response client.get("/actions/#{action_id}/card") end # Returns the list the comment is located def list List.from_response client.get("/actions/#{action_id}/list") end # Deletes the comment from the card def delete ruta = "/actions/#{action_id}" client.delete(ruta) end # Returns the member who created the comment. one :member_creator, via: Member, path: :members, using: :member_creator_id end |
Class Method Details
.find(action_id) ⇒ Object
Locate a specific action and return a new Comment object.
20 21 22 |
# File 'lib/trello/comment.rb', line 20 def find(action_id) client.find(:action, action_id, filter: commentCard) end |
Instance Method Details
#board ⇒ Object
Returns the board this comment is located
38 39 40 |
# File 'lib/trello/comment.rb', line 38 def board Board.from_response client.get("/actions/#{action_id}/board") end |
#card ⇒ Object
Returns the card the comment is located
43 44 45 |
# File 'lib/trello/comment.rb', line 43 def card Card.from_response client.get("/actions/#{action_id}/card") end |
#delete ⇒ Object
Deletes the comment from the card
53 54 55 56 |
# File 'lib/trello/comment.rb', line 53 def delete ruta = "/actions/#{action_id}" client.delete(ruta) end |
#list ⇒ Object
Returns the list the comment is located
48 49 50 |
# File 'lib/trello/comment.rb', line 48 def list List.from_response client.get("/actions/#{action_id}/list") end |
#update_fields(fields) ⇒ Object
Update the attributes of a Comment
Supply a hash of string keyed data retrieved from the Trello API representing a Comment.
29 30 31 32 33 34 35 |
# File 'lib/trello/comment.rb', line 29 def update_fields(fields) attributes[:action_id] = fields['id'] || attributes[:action_id] attributes[:text] = fields['data']['text'] || attributes[:text] attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date') attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id] self end |