Class: TaskMapper::Provider::Jira::Comment

Inherits:
Base::Comment
  • Object
show all
Defined in:
lib/provider/comment.rb

Overview

The comment class for taskmapper-jira

Do any mapping between taskmapper and your system’s comment model here versions of the ticket.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Comment

API = Jira::Comment # The class to access the api’s comments declare needed overloaded methods here



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/provider/comment.rb', line 12

def initialize(*object)
  if object.first
    object = object.first
    unless object.is_a? Hash
      @system_data = {:client => object}
      hash = {:id => object.id, 
        :author => object.author,
        :body => object.body,
        :created_at => object.created,
        :updated_at => object.updated,
        :ticket_id => object.ticket_id,
        :project_id => object.project_id}
    else
      hash = object
    end
    super(hash)
  end
end

Class Method Details

.find_all(ticket_id) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/provider/comment.rb', line 31

def self.find_all(ticket_id)
  begin 
    $jira.getComments("#{ticket_id}").map { |comment| self.new comment }
  rescue
    []
  end
end

.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object



39
40
41
# File 'lib/provider/comment.rb', line 39

def self.find_by_attributes(project_id, ticket_id, attributes = {}) 
  search_by_attribute(self.find_all(ticket_id), attributes)
end

.find_by_id(project_id, ticket_id, id) ⇒ Object



43
44
45
# File 'lib/provider/comment.rb', line 43

def self.find_by_id(project_id, ticket_id, id) 
  self.find_all(ticket_id).find { |comment| comment.id == id }
end