class TaskMapper::Provider::Bcx::Comment

Public Class Methods

create(attributes) click to toggle source
# File lib/provider/comment.rb, line 58
def create(attributes)
  project = attributes[:project_id]
  ticket = attributes[:ticket_id]

  comment = api.create_comment attributes
  comment = comment.merge({
    :project_id => project,
    :ticket_id => ticket
  })

  self.new comment
end
find_all(project_id, ticket_id) click to toggle source
# File lib/provider/comment.rb, line 47
def find_all(project_id, ticket_id)
  ticket = Ticket.find_by_id project_id, ticket_id
  ticket[:comments].collect do |comment|
    comment = comment.merge({
      :ticket_id => ticket_id,
      :project_id => project_id
    })
    self.new comment
  end
end
find_by_attributes(project_id, ticket_id, attributes = {}) click to toggle source
# File lib/provider/comment.rb, line 30
def find_by_attributes(project_id, ticket_id, attributes = {})
  search_by_attribute(self.find_all(project_id, ticket_id), attributes)
end
find_by_id(project_id, ticket_id, comment_id) click to toggle source
# File lib/provider/comment.rb, line 34
def find_by_id(project_id, ticket_id, comment_id)
  ticket = Ticket.find_by_id project_id, ticket_id
  if comment = ticket[:comments].find { |c| c[:id] == comment_id }
    comment = comment.merge({
      :ticket_id => ticket_id,
      :project_id => project_id
    })
    return self.new comment
  else
    return false
  end
end
new(*object) click to toggle source
Calls superclass method
# File lib/provider/comment.rb, line 4
def initialize(*object)
  object = object.first if object.is_a?(Array)
  super object if object.is_a?(Hash)
end

Private Class Methods

api() click to toggle source
# File lib/provider/comment.rb, line 72
def api
  TaskMapper::Provider::Bcx.api
end

Public Instance Methods

body() click to toggle source
# File lib/provider/comment.rb, line 9
def body
  self[:content]
end
created_at() click to toggle source
# File lib/provider/comment.rb, line 21
def created_at
  begin
    Time.parse(self[:created_at])
  rescue
    self[:created_at]
  end
end
updated_at() click to toggle source
# File lib/provider/comment.rb, line 13
def updated_at
  begin
    Time.parse(self[:updated_at])
  rescue
    self[:updated_at]
  end
end