Class: TaskMapper::Provider::Trac::Comment
- Inherits:
-
Base::Comment
- Object
- Base::Comment
- TaskMapper::Provider::Trac::Comment
- Defined in:
- lib/provider/comment.rb
Overview
The comment class for taskmapper-yoursystem
Do any mapping between taskmapper and your system’s comment model here versions of the ticket.
Class Method Summary collapse
- .find(project_id, ticket_id, *options) ⇒ Object
- .find_all(ticket_id) ⇒ Object
- .find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, ticket_id, id) ⇒ Object
Instance Method Summary collapse
- #created_at ⇒ Object
- #id ⇒ Object
-
#initialize(*object) ⇒ Comment
constructor
declare needed overloaded methods here.
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Comment
declare needed overloaded methods here
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/provider/comment.rb', line 11 def initialize(*object) if object.first object = object.first unless object.is_a? Hash @system_data = {:client => object} hash = {:id => object[:id], :author => object., :body => object.body, :ticket_id => object.ticket_id, :created_at => object.created_at, :updated_at => object.updated_at} else hash = object end super(hash) end end |
Class Method Details
.find(project_id, ticket_id, *options) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/provider/comment.rb', line 54 def self.find(project_id, ticket_id, *) if [0].first.is_a? Array self.find_all(ticket_id).select do |comment| comment if [0].any? { |id| id == comment.id } end elsif [0].first.is_a? Hash self.find_by_attributes(project_id, ticket_id, [0].first) else self.find_all(ticket_id) end end |
.find_all(ticket_id) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/provider/comment.rb', line 70 def self.find_all(ticket_id) comments = CommentUtil.new(ticket_id,TaskMapper::Provider::Trac.api).comments comments.compact.collect do |comment| TaskMapper::Provider::Trac::Comment.new comment end end |
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
49 50 51 52 |
# File 'lib/provider/comment.rb', line 49 def self.find_by_attributes(project_id, ticket_id, attributes = {}) comments = self.find_all(ticket_id) search_by_attribute(comments, attributes) end |
.find_by_id(project_id, ticket_id, id) ⇒ Object
66 67 68 |
# File 'lib/provider/comment.rb', line 66 def self.find_by_id(project_id, ticket_id, id) self.find_all(ticket_id).select { |comment| comment[:id] == id }.first end |
Instance Method Details
#created_at ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/provider/comment.rb', line 29 def created_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#id ⇒ Object
45 46 47 |
# File 'lib/provider/comment.rb', line 45 def id self[:id] end |
#updated_at ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/provider/comment.rb', line 37 def updated_at begin Time.parse(self[:updated_at]) rescue self[:updated_at] end end |