rename restrict by user
[dbsrgits/DBIx-Class-Schema-RestrictWithObject.git] / lib / DBIx / Class / Schema / RestrictByUser / RestrictComp / Source.pm
CommitLineData
772c89c1 1package DBIx::Class::Schema::RestrictByUser::RestrictComp::Source;
2
3use strict;
4use warnings;
5
6=head1 DESCRIPTION
7
8For general usage please see L<DBIx::Class::Schema::RestrictByUser>, the information
9provided here is not meant for general use and is subject to change. In the interest
10of transparency the functionality presented is documented, but all methods should be
11considered private and, as such, subject to incompatible changes and removal.
12
13=head1 PRIVATE METHODS
14
15=head2 resultset
16
17Intercept call to C<resultset> and return restricted resultset
18
19=cut
20
21sub resultset {
22 my $self = shift;
23 my $rs = $self->next::method(@_);
24 if (my $user = $self->schema->user) {
25 my $s = $self->source_name;
26 $s =~ s/::/_/g;
27 my $pre = $self->schema->restricted_prefix;
28 my $meth = "restrict_${s}_resultset";
29
30 if($pre){
31 my $meth_pre = "restrict_${pre}_${s}_resultset";
32 return $user->$meth_pre($rs) if $user->can($meth_pre);
33 }
34 $rs = $user->$meth($rs) if $user->can($meth);
35 }
36 return $rs;
37}
38
391;
40
41=head1 SEE ALSO
42
43L<DBIx::Class::Schema::RestrictByUser>,
44
45=cut