lib/ticketmaster/dummy/ticket.rb in ticketmaster-0.3.2 vs lib/ticketmaster/dummy/ticket.rb in ticketmaster-0.3.3
- old
+ new
@@ -2,34 +2,23 @@
module Dummy
# The Dummy Provider's Ticket class
class Ticket < TicketMaster::Provider::Base::Ticket
@system = :dummy
- # Find a ticket
- #
- # The implementation should be able to accept these cases if feasible:
- #
- # * find(:all) - Returns an array of all tickets
- # * find(##) - Returns a project based on that id or some other primary (unique) attribute
- # * find(:first, :summary => 'Ticket title') - Returns a ticket based on the ticket's attributes
- # * find(:summary => 'Test Ticket') - Returns all tickets based on the given attributes
- def self.find(*options)
- first = options.shift
- if first.nil? or first == :all
- [Ticket.new]
- elsif first == :first
- Ticket.new(options.shift)
- elsif first.is_a?(Hash)
- [Ticket.new(first)]
- end
+ def self.find_by_id(project_id, ticket_id)
+ self.new(project_id, {:id => ticket_id})
end
+
+ def self.find_by_attributes(*ticket_attributes)
+ [self.new(*ticket_attributes)]
+ end
# You don't need to define an initializer, this is only here to initialize dummy data
- def initialize(*options)
+ def initialize(project_id, *options)
data = {:id => rand(1000), :status => ['lol', 'rofl', 'lmao', 'lamo', 'haha', 'heh'][rand(6)],
:priority => rand(10), :summary => 'Tickets ticket ticket ticket', :resolution => false,
:created_at => Time.now, :updated_at => Time.now, :description => 'Ticket ticket ticket ticket laughing',
- :assignee => 'lol-man'}
+ :assignee => 'lol-man', :project_id => project_id}
@system = :dummy
super(data.merge(options.first || {}))
end
# Nothing to save so we always return true