Class: Trac::Ticket
- Inherits:
-
Object
- Object
- Trac::Ticket
- Defined in:
- lib/trac4r/ticket.rb
Overview
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
Instance Attribute Summary (collapse)
-
- (Object) cc
Returns the value of attribute cc.
-
- (Object) created_at
Returns the value of attribute created_at.
-
- (Object) description
Returns the value of attribute description.
-
- (Object) id
Returns the value of attribute id.
-
- (Object) keywords
Returns the value of attribute keywords.
-
- (Object) milestone
Returns the value of attribute milestone.
-
- (Object) owner
Returns the value of attribute owner.
-
- (Object) priority
Returns the value of attribute priority.
-
- (Object) reporter
Returns the value of attribute reporter.
-
- (Object) severity
Returns the value of attribute severity.
-
- (Object) status
Returns the value of attribute status.
-
- (Object) summary
Returns the value of attribute summary.
-
- (Object) type
Returns the value of attribute type.
-
- (Object) updated_at
Returns the value of attribute updated_at.
-
- (Object) version
Returns the value of attribute version.
Class Method Summary (collapse)
-
+ (Object) load(params)
loads a ticket from the XMLRPC response.
Instance Method Summary (collapse)
-
- (Object) check
checks if all attributes are set.
-
- (Ticket) initialize(id = 0)
constructor
returns a new ticket.
-
- (Object) method_missing(sym, *args)
If a method call has no args and matches an instance variable, we return its value.
Constructor Details
- (Ticket) initialize(id = 0)
returns a new ticket
22 23 24 25 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(sym, *args)
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
43 44 45 46 47 48 49 50 51 52 53 |
# 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 |
Instance Attribute Details
- (Object) cc
Returns the value of attribute cc
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def cc @cc end |
- (Object) created_at
Returns the value of attribute created_at
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def created_at @created_at end |
- (Object) description
Returns the value of attribute description
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def description @description end |
- (Object) id
Returns the value of attribute id
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def id @id end |
- (Object) keywords
Returns the value of attribute keywords
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def keywords @keywords end |
- (Object) milestone
Returns the value of attribute milestone
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def milestone @milestone end |
- (Object) owner
Returns the value of attribute owner
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def owner @owner end |
- (Object) priority
Returns the value of attribute priority
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def priority @priority end |
- (Object) reporter
Returns the value of attribute reporter
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def reporter @reporter end |
- (Object) severity
Returns the value of attribute severity
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def severity @severity end |
- (Object) status
Returns the value of attribute status
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def status @status end |
- (Object) summary
Returns the value of attribute summary
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def summary @summary end |
- (Object) type
Returns the value of attribute type
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def type @type end |
- (Object) updated_at
Returns the value of attribute updated_at
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def updated_at @updated_at end |
- (Object) version
Returns the value of attribute version
6 7 8 |
# File 'lib/trac4r/ticket.rb', line 6 def version @version end |
Class Method Details
+ (Object) load(params)
loads a ticket from the XMLRPC response
56 57 58 59 60 61 62 63 64 65 |
# 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 |
Instance Method Details
- (Object) check
checks if all attributes are set
28 29 30 31 32 33 |
# 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 |