Namespaces, please.

1 view
Skip to first unread message

andfurt...@gmail.com

unread,
Aug 3, 2007, 4:20:11 AM8/3/07
to mofo
In my application, I'd like to subclass HCard into a module called
Formats, so that I can call Formats::HCard.whatever(). This is proving
difficult (using mofo 0.2.7) because the different microformat classes
are not enclosed in a module. If they were, I could declare:

module Formats
class HCard < Microformats::HCard

but since I can't do that, I tried:

module Formats
class Formats::HCard < HCard

...which messes up the find() code because the @container variable
gets the value formats::hcard.

Putting those classes into a module for easy namespace differentiation
seems like the way to go here, though I might be overlooking a bit of
Ruby metaclass arcana that would help me do this with the code as-is.

Chris Wanstrath

unread,
Aug 3, 2007, 10:36:04 PM8/3/07
to mof...@googlegroups.com

> In my application, I'd like to subclass HCard into a module called
> Formats, so that I can call Formats::HCard.whatever(). This is proving
> difficult (using mofo 0.2.7) because the different microformat classes
> are not enclosed in a module.

You can set the container by hand ("container :hcard") to get around
this. However, I see your point. I just made microformats
subclass-safe.

http://projects.require.errtheblog.com/changesets/269

Your code should now work with the new gem. Thanks, lemme know if you
have any more issues.

--
Chris Wanstrath
http://errfree.com // http://errtheblog.com

Reply all
Reply to author
Forward
0 new messages