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