Help language development. Donate to The Perl Foundation

Red cpan:FCO last updated on 2020-11-22

lib/Red/Model.pm6
use Red::AST;

=head2 Red::Model

#| Base role for models
unit role Red::Model;

has $!filter;
#method gist { self.^attributes; #`{self.perl} }

multi method perl(::?CLASS:D:) {
    my @attrs = self.^attributes.grep({ !.^can("relationship-ast") && .has_accessor}).map: {
        "{ .name.substr(2) } => { .get_value(self).perl }"
    }
    "{ self.^name }.new({ @attrs.join: ", " })"
}