Name Change
[dbsrgits/DBIx-Class-Schema-RestrictWithObject.git] / lib / DBIx / Class / Schema / RestrictWithObject / RestrictComp / Source.pm
@@ -1,11 +1,11 @@
-package DBIx::Class::Schema::RestrictByUser::RestrictComp::Source;
+package DBIx::Class::Schema::RestrictWithObject::RestrictComp::Source;
 
 use strict;
 use warnings;
 
 =head1 DESCRIPTION
 
-For general usage please see L<DBIx::Class::Schema::RestrictByUser>, the information
+For general usage please see L<DBIx::Class::Schema::RestrictWithObject>, the information
 provided here is not meant for general use and is subject to change. In the interest
 of transparency the functionality presented is documented, but all methods should be
 considered private and, as such, subject to incompatible changes and removal.
@@ -17,21 +17,22 @@ considered private and, as such, subject to incompatible changes and removal.
 Intercept call to C<resultset> and return restricted resultset
 
 =cut
-  
+
 sub resultset {
   my $self = shift;
   my $rs = $self->next::method(@_);
-  if (my $user = $self->schema->user) {
+  if (my $obj = $self->schema->restricting_object) {
     my $s = $self->source_name;
     $s =~ s/::/_/g;
     my $pre = $self->schema->restricted_prefix;
     my $meth = "restrict_${s}_resultset";
-    
+
+    #if a prefix was set, try that first
     if($pre){
       my $meth_pre = "restrict_${pre}_${s}_resultset";
-      return $user->$meth_pre($rs) if $user->can($meth_pre);
-    }    
-    $rs = $user->$meth($rs) if $user->can($meth);
+      return $obj->$meth_pre($rs) if $obj->can($meth_pre);
+    }
+    $rs = $obj->$meth($rs) if $obj->can($meth);
   }
   return $rs;
 }
@@ -40,6 +41,6 @@ sub resultset {
 
 =head1 SEE ALSO
 
-L<DBIx::Class::Schema::RestrictByUser>,
+L<DBIx::Class::Schema::RestrictWithObject>,
 
 =cut