Cataly...tSchema(3pm)

πŸ“¦
version 0.66 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema β€” bestie, this one clones the schema with attributes for each request ✨ (it's a trait, and yes it's a mouthful, we call it Cataly...tSchema(3pm) around here πŸŽ€)


🌸 SYNOPSIS 🌸

okay so here's the vibe, you drop this in your config:

__PACKAGE__->config({
    traits => ['PerRequestSchema'],
});

sub per_request_schema_attributes {
    my ($self, $c) = @_;
    return (restricting_object => $c->user->obj);
}
### OR ###
sub per_request_schema {
    my ($self, $c) = @_;
    return $self->schema->schema_method($c->user->obj)
}

two ways to do it, pick your fighter πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like. every single new request? it clones the schema 🫢 with the attributes it scoops up from your per_request_schema_attributes method β€” which, heads up, you must implement, no skipping bestie 😭. that method gets handed the context ($c).

alternatively ✨ you could lowkey override the per_request_schema method instead, if you need access to the schema clone and/or you need to separate out the Model/Schema methods. it's giving "I have opinions about architecture" πŸ’… (see the examples up above and the defaults in the code, iykyk πŸ‘‘)


🌈 SEE ALSO 🌈

  • Catalyst::Model::DBIC::Schema
  • DBIx::Class::Schema

πŸ’œ AUTHOR πŸ’œ

see "AUTHOR" in Catalyst::Model::DBIC::Schema and "CONTRIBUTORS" in Catalyst::Model::DBIC::Schema 🫢 (the OGs fr fr)


see "COPYRIGHT" in Catalyst::Model::DBIC::Schema.


⭐ LICENSE ⭐

this program is free software, you can redistribute it and/or modify it under the same terms as Perl itself ✨ (slay, open source ate and left no crumbs)


and that's the whole page bestie!! πŸ₯³ this was the Cataly...tSchema(3pm) page from the User Contributed Perl Documentation, generated by perl v5.36.0 on 2023-10-26 πŸ’– go forth and clone responsibly πŸŒΈπŸ¦‹πŸ’…

πŸ“¦ where this page comes from