df254b3aaeb0f9069f50a9b1e5a5feafee3fcdcc
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / TraitFor / Model / DBIC / Schema / PerRequestSchema.pm
1 package Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema;
2 use Moose::Role;
3 use namespace::autoclean;
4
5 requires 'per_request_schema_attributes';
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