Both a Piece and a Collection?

1 view
Skip to first unread message

Steve Klabnik

unread,
Sep 1, 2010, 9:54:48 AM9/1/10
to Candy for Mongo
Hey there-

I also found out about Candy via the Sinatra mailing list, and came up
with a small project to try it out with. It's good stuff, except for
one small detail...

Can I work it out somehow that a class is both a Piece and a
Collection? I suspect not. Basically, I'm writing a small library with
my own amusing names for methods, and I need them to both be part of
the same class. Maybe my solution is to come up with an extra class to
hold the collection, and use it from the Piece somehow?

If I could emulate the 'User.new' / 'User.find' way that other ORMs
work, then that'd be fine.

Any advice would be appreciated.

Steve Klabnik

unread,
Sep 1, 2010, 10:56:20 AM9/1/10
to Candy for Mongo
As a secondary question, it appears that this doesn't work:

http://gist.github.com/560791

if line 6 just says collect :foo, it gets confused and tries to
instantiate the module. If I try 'Foo::Foo' as well, without the :, it
doesn't work either.

Is this a bug? Glancing at the source of collection.rb, I'm pretty
sure this doesn't work. Should I be doing this a different way, or
should I work on a patch?

Reply all
Reply to author
Forward
0 new messages