Class: TicketMaster::Provider::Codaset::Project

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

Overview

Project class for ticketmaster-codaset

Constant Summary collapse

API =

The class to access the api’s projects

CodasetAPI::Project

Instance Method Summary collapse

Constructor Details

#initialize(*options) ⇒ Project

Returns a new instance of Project.



18
19
20
# File 'lib/provider/project.rb', line 18

def initialize(*options)
  super(*options)
end

Instance Method Details

#copy(project) ⇒ Object

copy from this.copy(that) copies that into this



51
52
53
54
55
56
57
58
59
# File 'lib/provider/project.rb', line 51

def copy(project)
  project.tickets.each do |ticket|
    copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
    ticket.comments.each do |comment|
      copy_ticket.comment!(:body => comment.body)
      sleep 1
    end
  end
end

#created_atObject

declare needed overloaded methods here



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

def created_at
  @created_at ||= self[:created_at] ? Time.parse(self[:created_at]) : nil
end

#idObject



22
23
24
# File 'lib/provider/project.rb', line 22

def id
  self[:slug]
end

#nameObject



26
27
28
# File 'lib/provider/project.rb', line 26

def name
  self[:title]
end

#ticket!(*options) ⇒ Object



30
31
32
33
# File 'lib/provider/project.rb', line 30

def ticket!(*options)
  options[0].merge!(:slug => slug) if options.first.is_a?(Hash)
  provider_parent(self.class)::Ticket.create(*options)
end

#tickets(*options) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/provider/project.rb', line 35

def tickets(*options)
  begin 
  if options.first.is_a? Hash
    #options[0].merge!(:params => {:slug => slug})
    super(*options)
  elsif options.empty?
    tickets = CodasetAPI::Ticket.find(:all, :params => {:slug => slug}).collect { |ticket| TicketMaster::Provider::Codaset::Ticket.new ticket }
  else
    super(*options)
  end
  rescue
    []
  end
end

#updated_atObject



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

def updated_at
  @updated_at ||= self[:updated_at] ? Time.parse(self[:updated_at]) : nil
end