From: Gregory Brown Date: 2009-02-07T23:41:08+09:00 Subject: Re: Making object methods available externally On Thu, Feb 5, 2009 at 5:31 PM, David Stanford wrote: > Thanks for all the responses, guys. > > Judging from everyone's response, it sounds like what I'm trying to do > isn't typically done. My mindset was, first, to simply create a standard > class. While creating one of the object methods for that class, I > realized that the same method code would be useful to call directly, > without having to create an object instance; so, as I said, I was > thinking there must be some way to do this, without repeating the same > (or a similar piece) of code somewhere else. Probably s bit extreme for one method, but say you had 10 you wanted to do this with: module Foo def self.included(base) base.extend(self) end def method1; end def method2; end #... end class A include Foo # no need for manual extend call end Not tested or necessarily recommended. :) -greg -- Technical Blaag at: http://blog.majesticseacreature.com Non-tech stuff at: http://metametta.blogspot.com "Ruby Best Practices" Book now in O'Reilly Roughcuts: http://rubybestpractices.com