[ditz-talk] issue-timetracker plugin

Andrea Fazzi andrea.fazzi at alcacoop.it
Fri Feb 20 11:54:14 EST 2009

Il giorno ven, 20/02/2009 alle 11.15 -0500, Matthew Wilson ha scritto: 
> Sounds neat.  But how does your start command affect the start command
> already built into ditz?  Does it do everything the old one did AND
> start the clock?

Yes, it does. This is possible thanks to the ruby's capability to
re-open existing classes. Look at this excerpt from

class Issue
  alias :old_start_work :start_work
  alias :old_stop_work :stop_work
  def start_work(who, comment)
    self.mark_time = Time.now
    old_start_work(who, comment)
  def stop_work(who, comment)
    self.time_spent += Time.now - self.mark_time
    self.mark_time = Time.now
    old_stop_work(who, comment)

The code above re-opens the class Issue, then it saves the current
start_work and stop_work methods (aliasing) and finally it redefines
those method augmenting their functionalities.


More information about the ditz-talk mailing list