1 package Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema;
4 use namespace::autoclean;
6 requires 'per_request_schema_attributes';
8 with 'Catalyst::Component::InstancePerContext';
12 Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema - Clone the schema
13 with attributes for each requests
18 traits => ['PerRequestSchema'],
21 method per_request_schema_attributes($c) {
22 return (restricting_object => $c->user->obj);
27 Clones the schema for each new request with the attributes retrieved from your
28 C<per_request_schema_attributes> method, which you must implement. This method
29 is passed the context.
33 sub build_per_context_instance {
34 my ( $self, $ctx ) = @_;
35 return $self unless blessed($ctx);
37 my $new = bless {%$self}, ref $self;
39 $new->schema($new->schema->clone($self->per_request_schema_attributes($ctx)));
46 L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class::Schema>
50 See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
51 L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
55 See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
59 This program is free software, you can redistribute it and/or modify it
60 under the same terms as Perl itself.