Class: TaskMapper::Provider::Redmine::Ticket

Inherits:
Base::Ticket
  • Object
show all
Defined in:
lib/provider/ticket.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Ticket

declare needed overloaded methods here



10
11
12
13
14
15
16
# File 'lib/provider/ticket.rb', line 10

def initialize(*args)
  case args.first
    when Hash then super args.first
    when RedmineAPI::Issue then super args.first.to_ticket_hash
    else raise ArgumentError.new
  end
end

Class Method Details

.attributes_for_request(project_id, options) ⇒ Object



63
64
65
# File 'lib/provider/ticket.rb', line 63

def self.attributes_for_request(project_id, options)
 hash = {:params => {:project_id => project_id}}.merge!(options)
end

.create(attributes) ⇒ Object



67
68
69
70
# File 'lib/provider/ticket.rb', line 67

def self.create(attributes)
  ticket = self.new(attributes)
  ticket if ticket.save
end

.find_by_attributes(project_id, attributes = {}) ⇒ Object



58
59
60
61
# File 'lib/provider/ticket.rb', line 58

def self.find_by_attributes(project_id, attributes = {})
 issues = API.find(:all, attributes_for_request(project_id, attributes))
 issues.collect { |issue| self.new issue }
end

.find_by_id(project_id, ticket_id) ⇒ Object



54
55
56
# File 'lib/provider/ticket.rb', line 54

def self.find_by_id(project_id, ticket_id)
 self.new API.find(ticket_id)
end

Instance Method Details

#assigneeObject



42
43
44
# File 'lib/provider/ticket.rb', line 42

def assignee
  self[:author].name
end

#created_atObject



18
19
20
# File 'lib/provider/ticket.rb', line 18

def created_at
  self[:created_on]
end

#descriptionObject



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

def description
  self[:description]
end

#idObject



46
47
48
# File 'lib/provider/ticket.rb', line 46

def id
  self[:id].to_i
end

#priorityObject



34
35
36
# File 'lib/provider/ticket.rb', line 34

def priority
  self[:priority].name
end

#project_idObject



26
27
28
# File 'lib/provider/ticket.rb', line 26

def project_id
  self[:project_id]
end

#requestorObject



38
39
40
# File 'lib/provider/ticket.rb', line 38

def requestor
  self[:author].name
end

#saveObject



72
73
74
# File 'lib/provider/ticket.rb', line 72

def save
  to_issue.new? ? to_issue.save : update
end

#statusObject



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

def status
  self[:status].name
end

#updated_atObject



22
23
24
# File 'lib/provider/ticket.rb', line 22

def updated_at
  self[:updated_on]
end