Class: TicketMaster::Provider::Teambox::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TicketMaster::Provider::Teambox::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
The class to access the api’s tickets
Class Method Summary collapse
- .create(*options) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, task_id) ⇒ Object
- .search(project_id, options = {}, limit = 1000) ⇒ Object
Instance Method Summary collapse
- #comment!(*options) ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
declare needed overloaded methods here.
- #project_id ⇒ Object
- #task_id ⇒ Object
Constructor Details
#initialize(*object) ⇒ Ticket
declare needed overloaded methods here
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/provider/ticket.rb', line 9 def initialize(*object) if object.first args = object object = args.shift project_id = args.shift @system_data = {:client => object} unless object.is_a? Hash hash = {:status => object.status, :name => object.name, :updated_at => object.updated_at, :id => object.id, :project_id => project_id.nil? ? object.[:project_id] : project_id} else hash = object end super hash end end |
Class Method Details
.create(*options) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/provider/ticket.rb', line 28 def self.create(*) task = API.new(.first.merge!(:status => 1, :updated_at => Time.now )) ticket = self.new task task.save ticket end |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
46 47 48 |
# File 'lib/provider/ticket.rb', line 46 def self.find_by_attributes(project_id, attributes = {}) self.search(project_id, attributes) end |
.find_by_id(project_id, task_id) ⇒ Object
37 38 39 |
# File 'lib/provider/ticket.rb', line 37 def self.find_by_id(project_id, task_id) self.search(project_id, {:id => task_id}).first end |
.search(project_id, options = {}, limit = 1000) ⇒ Object
41 42 43 44 |
# File 'lib/provider/ticket.rb', line 41 def self.search(project_id, = {}, limit = 1000) tickets = API.find(:all, :params => {:project_id => project_id}).collect { |ticket| self.new ticket, project_id } self.search_by_attribute(tickets, , limit) end |
Instance Method Details
#comment!(*options) ⇒ Object
58 59 60 61 |
# File 'lib/provider/ticket.rb', line 58 def comment!(*) [0].update(:project_id => project_id, :task_id => task_id) if .first.is_a?(Hash) provider_parent(self.class)::Comment.create(*) end |
#project_id ⇒ Object
50 51 52 |
# File 'lib/provider/ticket.rb', line 50 def project_id self[:project_id] end |
#task_id ⇒ Object
54 55 56 |
# File 'lib/provider/ticket.rb', line 54 def task_id self[:id] end |