Class: TaskMapper::Provider::Bugherd::Comment

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

Overview

The comment class for taskmapper-bugherd

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

Constant Summary collapse

API =

The class to access the api’s comments

BugherdAPI::Comment

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Comment

declare needed overloaded methods here



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

def initialize(*object) 
  if object.first
    object = object.first
    @system_data = {:client => object}
    unless object.is_a? Hash
       hash = {:id => object.id,
               :created_at => object.created_at,
               :body => object.text,
               :user_id => object.user_id,
               :ticket_id => object.prefix_options[:task_id],
               :project_id => object.prefix_options[:project_id]}
    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.find_by_id(project_id, ticket_id, id) ⇒ Object



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

def self.find_by_id(project_id, ticket_id, id)
  self.new API.find(id, :params => {:project_id => project_id, :task_id => ticket_id})
end

.search(project_id, ticket_id, options = {}, limit = 1000) ⇒ Object



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

def self.search(project_id, ticket_id, options = {}, limit = 1000)
  API.find(:all, :params => {:project_id => project_id, :task_id => ticket_id}).collect do |comment|
    self.new comment
  end
end

Instance Method Details

#authorObject



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

def author
  author = BugherdAPI::User.find(:all).select do |user|
    user.id == self[:user_id]
  end.first
  "#{author.name} #{author.surname}" 
end