remove she-bang lines.
[catagits/Catalyst-Plugin-Authentication.git] / lib / Catalyst / Plugin / Authentication / User / Hash.pm
index db1783e..7f530a1 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
 package Catalyst::Plugin::Authentication::User::Hash;
 use base qw/Catalyst::Plugin::Authentication::User/;
 
@@ -9,29 +7,33 @@ use warnings;
 sub new {
     my $class = shift;
 
-    bless { ( @_ > 1 ) ? @_ : %{ $_[0] }  }, $class;
+    bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class;
 }
 
 sub AUTOLOAD {
     my $self = shift;
     ( my $key ) = ( our $AUTOLOAD =~ m/([^:]*)$/ );
 
-       $self->_accessor( $key, @_ );
+    $self->_accessor( $key, @_ );
 }
 
+# this class effectively handles any method calls
+sub can { 1 }
+
 sub id {
-       my $self = shift;
-       $self->_accessor( "id", @_ );
+    my $self = shift;
+    $self->_accessor( "id", @_ );
 }
 
-sub store {
-       my $self = shift;
-       ref $self || $self;
-}
+## deprecated. Let the base class handle this.
+#    sub store {
+#        my $self = shift;
+#        $self->_accessor( "store", @_ ) || ref $self;
+#    }
 
 sub _accessor {
-       my $self = shift;
-       my $key = shift;
+    my $self = shift;
+    my $key  = shift;
 
     if (@_) {
         my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1;
@@ -44,6 +46,7 @@ sub _accessor {
       : $data;
 }
 
+## password portion of this is no longer necessary, but here for backwards compatibility.
 my %features = (
     password => {
         clear      => ["password"],
@@ -60,10 +63,11 @@ sub supports {
 
     my $cursor = \%features;
 
+    return 1 if @spec == 1 and exists $self->{ $spec[0] };
+
     # traverse the feature list,
     for (@spec) {
-        die "bad feature spec: @spec"
-          if ref($cursor) ne "HASH";
+        return if ref($cursor) ne "HASH";
         $cursor = $cursor->{$_};
     }
 
@@ -84,12 +88,13 @@ sub supports {
 
 sub for_session {
     my $self = shift;
-    return $self;    # let's hope we're serialization happy
+    
+    return $self; # we serialize the whole user
 }
 
 sub from_session {
-       my ( $self, $c, $user ) = @_;
-       $user;
+    my ( $self, $c, $user ) = @_;
+    $user;
 }
 
 __PACKAGE__;
@@ -140,6 +145,12 @@ Just passes returns the unserialized object, hoping it's intact.
 
 Accessor for the key whose name is the method.
 
+=item id
+
+=item store
+
+Accessors that override superclass's dying virtual methods.
+
 =back
 
 =head1 SEE ALSO