lib/ticketmaster/dummy/project.rb in ticketmaster-0.3.2 vs lib/ticketmaster/dummy/project.rb in ticketmaster-0.3.3
- old
+ new
@@ -1,27 +1,22 @@
module TicketMaster::Provider
module Dummy
# This is the Project class for the Dummy provider
class Project < TicketMaster::Provider::Base::Project
- # This serves to find projects
- # As noted in the Project class's documentation, we should try to accept these:
- #
- # * find(:all) - Returns an array of all projects
- # * find(##) - Returns a project based on that id or some other primary (unique) attribute
- # * find(:first, :summary => 'Project name') - Returns a project based on the project's attributes
- # * find(:summary => 'Test Project') - Returns all projects based on the given attribute(s)
- def self.find(*options)
- first = options.shift
- if first.nil? or first == :all
- [Project.new]
- elsif first == :first
- Project.new(options.shift)
- elsif first.is_a?(Hash)
- [Project.new(first)]
- end
+
+ def self.find_by_id(id)
+ self.new({:id => id})
end
+ def self.find_by_attributes(*options)
+ [self.new(*options)]
+ end
+
+ def self.create(*attributes)
+ self.new(*attributes)
+ end
+
# You should define @system and @system_data here.
# The data stuff is just to initialize fake data. In a real provider, you would use the API
# to grab the information and then initialize based on that info.
# @system_data would hold the API's model/instance for reference
def initialize(*options)
@@ -29,30 +24,18 @@
:created_at => Time.now, :updated_at => Time.now}
@system = :dummy
super(data.merge(options.first || {}))
end
- # Should return all of the project's tickets
- def tickets(*options)
- return Ticket.find(*options) if options.length > 0
- [Ticket.new]
- end
-
- # Point it to the Dummy's Ticket class
- def ticket(*options)
- return Ticket.find(:first, options.first) if options.length > 0
- Ticket
- end
-
# Nothing to save so we always return true
# ...unless it's an odd numbered second on Friday the 13th. muhaha!
def save
time = Time.now
!(time.wday == 5 and time.day == 13 and time.to_i % 2 == 1)
end
# Nothing to update, so we always return true
- def update(*options)
+ def update!(*options)
return true
end
end
end
end