Commit | Line | Data |
79ac28c6 |
1 | package Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema; |
2a9509a4 |
2 | use Moose::Role; |
79ac28c6 |
3 | use namespace::autoclean; |
4 | |
2a9509a4 |
5 | requires 'per_request_schema_attributes'; |
79ac28c6 |
6 | |
7 | with 'Catalyst::Component::InstancePerContext'; |
8 | |
9 | sub build_per_context_instance { |
10 | my ( $self, $ctx ) = @_; |
11 | return $self unless blessed($ctx); |
12 | |
13 | my $new = bless {%$self}, ref $self; |
14 | |
15 | $new->schema( $new->schema->clone($self->per_request_schema_attributes($ctx)) ); |
16 | |
17 | return $new; |
18 | } |
19 | |
20 | __PACKAGE__->meta->make_immutable; |
21 | |