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(ticket_id, *options) ⇒ Object



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

def self.find(ticket_id, *options)
  if options.first.empty?
    self.find_all(ticket_id)
  end
end

.find_all(ticket_id) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/provider/comment.rb', line 37

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