use class << self instead of self. 
you can find here an illustration on how this can be done: http://www.railstips.org/blog/archives/2009/05/11/class-and-instance-methods-in-ruby/