[rspec-users] class << self considered harmful... really?

Mark Wilden mark at mwilden.com
Wed Nov 26 09:46:33 EST 2008

On Wed, Nov 26, 2008 at 5:23 AM, Shot (Piotr Szotkowski) <shot at hot.pl>wrote:

> Such methods have access to the eigenclass's instance variables, and so
> class << self works very nice when working with singletons (like Log or
> Config).
> If you don't use class << self, you have to work on class variables and
> you can't use the attr_* shorthands to access the singleton's variables.

Right. I was talking about the difference between using "class << self" and
"def self.foo" when other things were equal. I do understand there are
situations (like the one you mention) where it's handy to be actually in the
eigenclass when defining methods.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081126/ea310533/attachment-0001.html>

More information about the rspec-users mailing list