Class: TaskMapper::Provider::Bcx::Comment
- Inherits:
-
TaskMapper::Provider::Base::Comment
- Object
- TaskMapper::Provider::Base::Comment
- TaskMapper::Provider::Bcx::Comment
- Defined in:
- lib/provider/comment.rb
Class Method Summary collapse
- .create(attributes) ⇒ Object
- .find_all(project_id, ticket_id) ⇒ Object
- .find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, ticket_id, comment_id) ⇒ Object
Instance Method Summary collapse
- #body ⇒ Object
- #created_at ⇒ Object
-
#initialize(*object) ⇒ Comment
constructor
A new instance of Comment.
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Comment
Returns a new instance of Comment.
4 5 6 7 |
# File 'lib/provider/comment.rb', line 4 def initialize(*object) object = object.first if object.is_a?(Array) super object if object.is_a?(Hash) end |
Class Method Details
.create(attributes) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/provider/comment.rb', line 58 def create(attributes) project = attributes[:project_id] ticket = attributes[:ticket_id] comment = api.create_comment attributes comment = comment.merge({ :project_id => project, :ticket_id => ticket }) self.new comment end |
.find_all(project_id, ticket_id) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/provider/comment.rb', line 47 def find_all(project_id, ticket_id) ticket = Ticket.find_by_id project_id, ticket_id ticket[:comments].collect do |comment| comment = comment.merge({ :ticket_id => ticket_id, :project_id => project_id }) self.new comment end end |
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
30 31 32 |
# File 'lib/provider/comment.rb', line 30 def find_by_attributes(project_id, ticket_id, attributes = {}) search_by_attribute(self.find_all(project_id, ticket_id), attributes) end |
.find_by_id(project_id, ticket_id, comment_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/provider/comment.rb', line 34 def find_by_id(project_id, ticket_id, comment_id) ticket = Ticket.find_by_id project_id, ticket_id if comment = ticket[:comments].find { |c| c[:id] == comment_id } comment = comment.merge({ :ticket_id => ticket_id, :project_id => project_id }) return self.new comment else return false end end |
Instance Method Details
#body ⇒ Object
9 10 11 |
# File 'lib/provider/comment.rb', line 9 def body self[:content] end |
#created_at ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/provider/comment.rb', line 21 def created_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#updated_at ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/provider/comment.rb', line 13 def updated_at begin Time.parse(self[:updated_at]) rescue self[:updated_at] end end |