Skip to content

Not able to create subset directly #4

@jonathanstowe

Description

@jonathanstowe

Because a Red::Model isn't quite the right type of, er, type the pattern suggested in the https://cro.services/docs/http-auth-and-sessions to create subsets of the UserSession object like:

subset Admin of My::App::Session where .is-admin;
subset LoggedIn of My::App::Session where .is-logged-in;

Won't work directly (giving The 'of' type of a subset must either be a valid nominal type or a type that can provide one ) so one has to make an intermediate subset instead like:

subset UserSession of Cro::HTTP::Auth where * ~~ My::App::Session;
subset Admin of  UserSession where .is-admin;
subset LoggedIn of UserSession where .is-logged-in;

(Assuming My::App::Session is your Red model.)

I don't think this can easily be fixed given the way Red works (and would have to be done in Red itself besides,) but is probably worth noting in the documentation to avoid a future issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions