lib/roart/ticket.rb in roart-0.1.8 vs lib/roart/ticket.rb in roart-0.1.9
- old
+ new
@@ -1,10 +1,10 @@
module Roart
module Tickets
- DefaultAttributes = %w(queue owner creator subject status priority initial_priority final_priority requestors cc admin_cc created starts started due resolved told last_updated time_estimated time_worked time_left text)
+ DefaultAttributes = %w(queue owner creator subject status priority initial_priority final_priority requestors cc admin_cc created starts started due resolved told last_updated time_estimated time_worked time_left text).inject({}){|memo, k| memo[k] = nil; memo}
RequiredAttributes = %w(queue subject)
end
class Ticket
@@ -21,13 +21,13 @@
# ticket = MyTicket.new(:queue => "Some Queue", :subject => "The System is Down.")
# ticket.id #-> This will be the ID of the ticket in the RT System.
#
def initialize(attributes=nil)
if attributes
- @attributes = Roart::Tickets::DefaultAttributes.to_hash.merge(attributes)
+ @attributes = Roart::Tickets::DefaultAttributes.merge(attributes)
else
- @attributes = Roart::Tickets::DefaultAttributes.to_hash
+ @attributes = Roart::Tickets::DefaultAttributes
end
@attributes.update(:id => 'ticket/new')
@saved = false
@history = false
@new_record = true
@@ -314,16 +314,18 @@
for ticket in page
ticket = self.instantiate(ticket)
ticket.instance_variable_set("@full", true)
array << ticket
end
- array
+ array ||= []
end
def get_ticket_from_uri(uri) #:nodoc:
page = page_array(uri)
page.extend(Roart::TicketPage)
- page = page.to_hash
+ unless page = page.to_hash
+ raise TicketNotFoundError, "No ticket matching search criteria found."
+ end
ticket = self.instantiate(page)
ticket.instance_variable_set("@full", true)
ticket
end