Class: TaskMapper::Provider::Bcx::Ticket
- Inherits:
-
TaskMapper::Provider::Base::Ticket
- Object
- TaskMapper::Provider::Base::Ticket
- TaskMapper::Provider::Bcx::Ticket
- Defined in:
- lib/provider/ticket.rb
Class Method Summary collapse
- .create(attributes) ⇒ Object
- .find_all(project_id) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, ticket_id) ⇒ Object
Instance Method Summary collapse
- #close ⇒ Object
- #created_at ⇒ Object
- #description ⇒ Object
- #description=(string) ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
A new instance of Ticket.
- #reopen ⇒ Object
- #save ⇒ Object
- #status ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Ticket
Returns a new instance of Ticket.
4 5 6 7 |
# 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 |
Class Method Details
.create(attributes) ⇒ Object
69 70 71 72 73 |
# 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) ⇒ Object
56 57 58 59 60 61 |
# 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 = {}) ⇒ Object
52 53 54 |
# 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) ⇒ Object
63 64 65 66 67 |
# 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 |
Instance Method Details
#close ⇒ Object
33 34 35 36 |
# File 'lib/provider/ticket.rb', line 33 def close self[:completed] = true save end |
#created_at ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/provider/ticket.rb', line 43 def created_at begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#description ⇒ Object
9 10 11 |
# File 'lib/provider/ticket.rb', line 9 def description self[:content] end |
#description=(string) ⇒ Object
13 14 15 |
# File 'lib/provider/ticket.rb', line 13 def description=(string) self[:content] = string end |
#reopen ⇒ Object
38 39 40 41 |
# File 'lib/provider/ticket.rb', line 38 def reopen self[:completed] = false save end |
#save ⇒ Object
29 30 31 |
# File 'lib/provider/ticket.rb', line 29 def save api.update_todo self end |
#status ⇒ Object
17 18 19 |
# File 'lib/provider/ticket.rb', line 17 def status self[:completed] ? 'closed' : 'open' end |
#updated_at ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/provider/ticket.rb', line 21 def updated_at begin Time.parse(self[:updated_at]) rescue self[:updated_at] end end |