class TaskMapper::Provider::Bcx::Ticket

Public Class Methods

create(attributes) click to toggle source
# File lib/provider/ticket.rb, line 69
def create(attributes)
  todo = api.create_todo attributes
  todo = Hash[todo].merge({:project_id => attributes[:project_id]})
  self.new todo
end
find_all(project_id) click to toggle source
# File lib/provider/ticket.rb, line 56
def find_all(project_id)
  todos = api.todos project_id
  todos = todos.select { |todo| todo.is_a?(Hash) }
  todos.each { |t| t.merge!({:project_id => project_id})}
  todos.collect { |todo| self.new todo }
end
find_by_attributes(project_id, attributes = {}) click to toggle source
# File lib/provider/ticket.rb, line 52
def find_by_attributes(project_id, attributes = {})
  search_by_attribute(self.find_all(project_id), attributes)
end
find_by_id(project_id, ticket_id) click to toggle source
# File lib/provider/ticket.rb, line 63
def find_by_id(project_id, ticket_id)
  todo = api.todo project_id, ticket_id
  todo = Hash[todo].merge({:project_id => project_id})
  self.new todo
end
new(*object) click to toggle source
Calls superclass method
# File lib/provider/ticket.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/ticket.rb, line 76
def api
  TaskMapper::Provider::Bcx.api
end

Public Instance Methods

close() click to toggle source
# File lib/provider/ticket.rb, line 33
def close
  self[:completed] = true
  save
end
created_at() click to toggle source
# File lib/provider/ticket.rb, line 43
def created_at
  begin
    Time.parse(self[:created_at])
  rescue
    self[:created_at]
  end
end
description() click to toggle source
# File lib/provider/ticket.rb, line 9
def description
  self[:content]
end
description=(string) click to toggle source
# File lib/provider/ticket.rb, line 13
def description=(string)
  self[:content] = string
end
reopen() click to toggle source
# File lib/provider/ticket.rb, line 38
def reopen
  self[:completed] = false
  save
end
save() click to toggle source
# File lib/provider/ticket.rb, line 29
def save
  api.update_todo self
end
status() click to toggle source
# File lib/provider/ticket.rb, line 17
def status
  self[:completed] ? 'closed' : 'open'
end
updated_at() click to toggle source
# File lib/provider/ticket.rb, line 21
def updated_at
  begin
    Time.parse(self[:updated_at])
  rescue
    self[:updated_at]
  end
end

Private Instance Methods

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