Alle 21:09, gioved4 gennaio 2007, Jeff ha scritto:
> I happened to be reading dependencies.rb in the Rails source, and it
> starts like this:
>
> require 'set'
> require File.dirname(__FILE__) + '/core_ext/module/attribute_accessors'
> require File.dirname(__FILE__) + '/core_ext/load_error'
> require File.dirname(__FILE__) + '/core_ext/kernel'
>
> module Dependencies #:nodoc:
>   extend self
> ...
>
>
> What is the "extend self" doing?  I thought at the top a module, 'self'
> was pretty much an empty context at that point... but I guess not,
> since the writer obviously thinks self contains something worth
> extending...?
>
> Jeff

In a module definition, outside methods, self refers to the module itself, as 
it happens inside the definition of a class. For instance, the following code

module MyModule
  puts self.class
  puts self.name
end

gives

Module
MyModule