class TicketMaster::Provider::Rally::Project

Project class for ticketmaster-rally

Remaps

id => oid created_at => creation_date updated_at => creation_date

Public Class Methods

find_by_attributes(attributes = {}) click to toggle source

Accepts an attributes hash and returns all projects matching those attributes in an array Should return all projects if the attributes hash is empty

# File lib/provider/project.rb, line 59
def self.find_by_attributes(attributes = {})
  self.search(attributes)
end
find_by_id(id) click to toggle source

Accepts an integer id and returns the single project instance

# File lib/provider/project.rb, line 50
def self.find_by_id(id)
  # Rally Ruby REST API expects IDs as strings
  # For id.to_s see note on Project::id
  query_result = TicketMaster::Provider::Rally.rally.find(:project, :fetch => true) { equal :object_i_d, id.to_s }
  self.new query_result.first
end
new(*object) click to toggle source
Calls superclass method
# File lib/provider/project.rb, line 12
def initialize(*object)
  if object.first
    project = object.first
    # Store Rally Project object in Ticketmaster Project object
    # This allows Ticketmaster to perform updates on Rally Project
    @system_data = {:client => project}
    hash = {:oid => project.oid, 
            :name => project.name, 
            :description => project.description,
            :created_at => project.creation_date, 
            # Rally Project object does not have a modified time
            :updated_at => project.creation_date}           
    super hash
  end
end

Public Instance Methods

copy(project) click to toggle source

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

# File lib/provider/project.rb, line 72
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_at() click to toggle source
# File lib/provider/project.rb, line 28
def created_at
  Time.parse(self[:created_at])
end
id() click to toggle source

Rally REST API aliases String and Fixnum :to_q :to_s However, it does not alias Bignum If a ID is a Bignum, the API will throw undefined method Because of this, we pass all IDs to API as strings Ticketmaster specs set IDs as integers, so coerce type on get

# File lib/provider/project.rb, line 41
def id
  self[:oid].to_i
end
id=(id) click to toggle source
# File lib/provider/project.rb, line 45
def id=(id)
  self[:oid] = id.to_s
end
updated_at() click to toggle source
# File lib/provider/project.rb, line 32
def updated_at
  Time.parse(self[:updated_at])
end