Class: TaskMapper::Provider::Redmine::Comment
- Inherits:
-
Base::Comment
- Object
- Base::Comment
- TaskMapper::Provider::Redmine::Comment
- Defined in:
- lib/provider/comment.rb
Overview
The comment class for taskmapper-redmine
Constant Summary collapse
- API =
RedmineAPI::Issue
Class Method Summary collapse
- .create(*options) ⇒ Object
- .find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, ticket_id, id) ⇒ Object
- .search(ticket_id) ⇒ Object
Instance Method Summary collapse
-
#initialize(ticket_id, *object) ⇒ Comment
constructor
A new instance of Comment.
- #save ⇒ Object
Constructor Details
#initialize(ticket_id, *object) ⇒ Comment
Returns a new instance of Comment.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/provider/comment.rb', line 7 def initialize(ticket_id, *object) if object.first object = object.first unless object.is_a? Hash = object.respond_to?(:user) ? object.user : object. hash = {:id => object.id.to_i, :author => .name, :body => object.notes, :update_at => object.created_on, :created_at => object.created_on, :ticket_id => ticket_id } else hash = object end super hash end end |
Class Method Details
.create(*options) ⇒ Object
45 46 47 48 |
# File 'lib/provider/comment.rb', line 45 def self.create(*) attributes = .first self.new(attributes[:ticket_id], create_journal_for_issue(attributes)) end |
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
34 35 36 |
# File 'lib/provider/comment.rb', line 34 def self.find_by_attributes(project_id, ticket_id, attributes = {}) search_by_attribute(self.search(ticket_id), attributes) end |
.find_by_id(project_id, ticket_id, id) ⇒ Object
30 31 32 |
# File 'lib/provider/comment.rb', line 30 def self.find_by_id(project_id, ticket_id, id) self.search(ticket_id).select { |journal| journal.id == id.to_i }.first end |
.search(ticket_id) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/provider/comment.rb', line 38 def self.search(ticket_id) API.find(ticket_id).journals.inject([]) do |arr, journal| arr << self.new(ticket_id, journal) if journal.notes.present? arr end end |
Instance Method Details
#save ⇒ Object
26 27 28 |
# File 'lib/provider/comment.rb', line 26 def save raise TaskMapper::Exception.new "Redmine API doesn't support comment updates" end |