Sean Cribbs sean at basho.com
Fri Feb 11 16:20:57 EST 2011

Ripple supports "single-bucket inheritance". All stored documents contain a "_type" field in the stored JSON object.  However, 'find' calls are not scoped to specific types (no indices!), so you must be aware that the type instantiated might not be the same as the requested type.  

PDI: A check could be added to 'instantiate' to verify that the selected class is a descendant of the requested class.

Sean Cribbs <sean at basho.com>
Developer Advocate
Basho Technologies, Inc.

On Feb 11, 2011, at 4:10 PM, Mat Ellis wrote:

> We build lots of interfaces to other systems. Generally we like to do this using Polymorphism. For instance, if we had to interface with 50 different publishers of books, we'd have one class called "Publisher" with the core logic and then interface specific overrides as "PenguinPublisher", "RandomHousePublisher", etc.
> When using Ripple this seems to be partially broken. We can use various sub-classes and they will behave as before. But now I can say "PenguinPublisher.find("RandomHouse")" and it will return a Publisher object. Also, when I create a "PenguinPublisher" object it won't set the type field correctly. I've tried overriding this (by adding property :type, String, :default => "PenguinPublisher" in the PenguinPublisher sub-class) and also ommitting the type field in the parent class (which then makes all Publishers without a type set fail and still doesn't fix the 'issue').
> This isn't stopping us from using sub-classes. I would like to know:
> (a) if there is any fundamental reason why we couldn't have polymorphism 
> (b) if the answer to (a) is no, is it on the roadmap?
> (c) what kind of problems should we be looking out for with this until/if polymorphism is fully supported
> We're still getting our heads around Riak so apologies in advance if this is a dumb question. We decided to cut over the entire schema (including the stuff that doesn't really need Riak and may actually be a bit harder to do on it) to keep things simpler.
> Cheers
> M.
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

More information about the riak-users mailing list