release 0.56
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / TraitFor / Model / DBIC / Schema / PerRequestSchema.pm
CommitLineData
79ac28c6 1package Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema;
2a9509a4 2use Moose::Role;
79ac28c6 3use namespace::autoclean;
4
2a9509a4 5requires 'per_request_schema_attributes';
79ac28c6 6
7with 'Catalyst::Component::InstancePerContext';
8
9sub 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