Class: TicketMaster::Provider::Dummy::Project

Inherits:
Base::Project
  • Object
show all
Defined in:
lib/ticketmaster/dummy/project.rb

Overview

This is the Project class for the Dummy provider

Constant Summary

Constants inherited from Base::Project

Base::Project::API

Instance Attribute Summary

Attributes inherited from Base::Project

#system, #system_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Project

find, first, last, search, #ticket, #ticket!, #tickets

Methods included from Helper

#easy_finder, #filter_string, #provider_parent, #search_by_attribute, #search_filter, #this_method

Methods included from Common

#destroy, included, #respond_to?

Constructor Details

#initialize(*options) ⇒ Project

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.



22
23
24
25
26
27
# File 'lib/ticketmaster/dummy/project.rb', line 22

def initialize(*options)
  data = {:id => rand(1000).to_i, :name => 'Dummy', :description => 'Mock!-ing Bird',
    :created_at => Time.now, :updated_at => Time.now}
  @system = :dummy
  super(data.merge(options.first || {}))
end

Class Method Details

.create(*attributes) ⇒ Object



14
15
16
# File 'lib/ticketmaster/dummy/project.rb', line 14

def self.create(*attributes)
  self.new(*attributes)
end

.find_by_attributes(*options) ⇒ Object



10
11
12
# File 'lib/ticketmaster/dummy/project.rb', line 10

def self.find_by_attributes(*options)
  [self.new(*options)]
end

.find_by_id(id) ⇒ Object



6
7
8
# File 'lib/ticketmaster/dummy/project.rb', line 6

def self.find_by_id(id)
  self.new({:id => id})
end

Instance Method Details

#saveObject

Nothing to save so we always return true …unless it’s an odd numbered second on Friday the 13th. muhaha!



31
32
33
34
# File 'lib/ticketmaster/dummy/project.rb', line 31

def save
  time = Time.now
  !(time.wday == 5 and time.day == 13 and time.to_i % 2 == 1)
end

#update!(*options) ⇒ Object

Nothing to update, so we always return true



37
38
39
# File 'lib/ticketmaster/dummy/project.rb', line 37

def update!(*options)
  return true
end