Skip to content

STI Equivalent #6

Description

@tapajos

Issue from: http://github.com/couchrest/couchrest/issues#issue/18

Hello,

Has anyone already thought of starting to work on something similar to active record's single table inheritance ?

Let's guess two classes :

class User < CouchRest::ExtendedDocument
end

class Admin < User
end

Currently, couchrest wouldn't see that the admin is in fact a user. We couldn't retrieve all users (admins included).

The idea would be, when a class inherits from an other, to add an attribute "couchrest-sti", which would have the subclass value.
When we do a User.all, it's retrieve all the objects having "couchrest-type" defined to user.
But if it has a "couchrest-sti" defined, it'd instantiate the object as the class defined in that attribute. Not as a user.

I really need this. So I'd be willing to work on it. But is it something you'd find useful and that'd have a chance to get implemented to the trunk ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions