Parent

Files

Class/Module Index [+]

Quicksearch

Trac::Ticket

This class represents a ticket as it is retrieved from the database Custom fields are detected and available via runtime-dispatched methods. See method_missing

Attributes

cc[RW]
created_at[RW]
description[RW]
id[RW]
keywords[RW]
milestone[RW]
owner[RW]
priority[RW]
reporter[RW]
severity[RW]
status[RW]
summary[RW]
type[RW]
updated_at[RW]
version[RW]

Public Class Methods

load(params) click to toggle source

loads a ticket from the XMLRPC response

# File lib/trac4r/ticket.rb, line 56
def self.load params
  ticket = self.new params[0]
  ticket.created_at = params[1]
  ticket.updated_at = params[2]
  attributes = params[3]
  attributes.each do |key,value|
    ticket.instance_variable_set("@#{key}".to_sym,value)
  end
  return ticket
end
new(id=0) click to toggle source

returns a new ticket

# File lib/trac4r/ticket.rb, line 22
def initialize id=0
  @id = id
  @severity=@milestone=@status=@type=@priority=@version=@reporter=@owner= @cc= @summary=@description=@keywords=""
end

Public Instance Methods

check() click to toggle source

checks if all attributes are set

# File lib/trac4r/ticket.rb, line 28
def check
  instance_variables.each do |v|
    return false if instance_variable_get(v.to_sym).nil?
  end
  return true
end
method_missing(sym,*args) click to toggle source

If a method call has no args and matches an instance variable, we return its value. e.g. if our tickets have a custom field called work_units, then some_ticket.work_units will retrieve that value. This currently only allows retrieval and not updating the value. Also note that you can retrieve a custom field using “!” and this will silently return nil if the instance variable didn’t exist. This is useful if some tickets just don’t have the custom field, but you don’t wish to check for it

# File lib/trac4r/ticket.rb, line 43
def method_missing(sym,*args)
  method = sym.to_s
  method = method[0..-2] if method =~ /!$/
  if args.size == 0 && instance_variables.include?("@#{method}".to_sym)
    instance_eval("@" + sym.to_s)
  elsif method != sym.to_s
    nil
  else
    super.method_missing(sym,args)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.