Because he does not know that
def GeoPlanet::Base.build_url(resource_path, options = {}) end
will work just as well?
Well, they are not 100% equivalent: if GeoPlanet does not exist, then the source fragment will create a module, but my version will raise a NameError . To get around this, you will need to do this:
module GeoPlanet def Base.build_url(resource_path, options = {}) end end
Which, of course, raises a NameError if Base does not exist. To get around this, you would do:
module GeoPlanet class Base def self.build_url(resource_path, options = {}) end end end
However, you look at it; there is no need to use the syntax of the singleton class. Some people just prefer it.
source share