Class: TaskMapper::Provider::Bugzilla::Comment

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

Class Method Summary collapse

Instance Method Summary collapse

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
28
# 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,
              :ticket_id => object.bug_id,
              :body => object.text,
              :author => object.creator,
              :created_at => object.time,
              :updated_at => object.time}

    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.find(ticket_id, *options) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/provider/comment.rb', line 54

def self.find(ticket_id, *options)
  if options.first.empty?
    COMMENT_API.new(ticket_id).comments.collect { |comment| self.new comment }
  elsif options[0].first.is_a? Array
     COMMENT_API.new(ticket_id).comments(:comment_ids => options[0].first).collect { |comment| self.new comment }
  end
end

.find_by_id(ticket_id, id) ⇒ Object



50
51
52
# File 'lib/provider/comment.rb', line 50

def self.find_by_id(ticket_id, id)
  self.new COMMENT_API.new(ticket_id).comments(:comment_ids => [id]).first
end

Instance Method Details

#bodyObject



30
31
32
# File 'lib/provider/comment.rb', line 30

def body
  self[:text]
end

#created_atObject



34
35
36
37
38
39
40
# File 'lib/provider/comment.rb', line 34

def created_at
  begin
    normalize_datetime(self[:time])
  rescue
    self[:created_at]
  end
end

#updated_atObject



42
43
44
45
46
47
48
# File 'lib/provider/comment.rb', line 42

def updated_at
  begin
    normalize_datetime(self[:time])
  rescue
    self[:updated_at]
  end
end