weave some pod
[catagits/Catalyst-Plugin-Session-State-Stash.git] / lib / Catalyst / Plugin / Session / State / Stash.pm
index 438b910..962bada 100644 (file)
@@ -1,19 +1,21 @@
 package Catalyst::Plugin::Session::State::Stash;
-use base qw/Catalyst::Plugin::Session::State Class::Accessor::Fast/;
+# ABSTRACT: Maintain session IDs using the stash
 
-#Need to look up which version of perl is required.
-#use 5.008;
-use strict;
-use warnings;
+use Moose;
+use 5.008;
 use MRO::Compat;
+use namespace::autoclean;
 
-our $VERSION = "0.10";
+extends 'Catalyst::Plugin::Session::State';
 
-BEGIN { __PACKAGE__->mk_accessors(qw/_deleted_session_id _prepared/) }
+our $VERSION = '0.14';
+
+has _deleted_session_id => ( is => 'rw' );
+has _prepared => ( is => 'rw' );
 
 sub _stash_key_components {
     my ($c) = @_;
-    my $config = $c->config->{'Plugin::Session'} || $c->config->{'session'};
+    my $config = $c->_session_plugin_config;
     return ($config->{stash_delim}) ?
         split $config->{stash_delim}, $config->{stash_key} :
         $config->{stash_key};
@@ -29,17 +31,15 @@ sub _get_session {
 
 sub _set_session {
     my ( $c,$key,$value) = @_;
-    
     $c->_get_session->{$key} = $value;
 }
 
 sub setup_session {
     my $c = shift;
 
-    $c->config->{'Plugin::Session'} 
-        and return $c->config->{'Plugin::Session'}->{stash_key} |= '_session';
-    $c->config->{'session'}->{stash_key}
-        ||= '_session';
+    $c->maybe::next::method(@_);
+
+    $c->_session_plugin_config->{stash_key} ||= '_session';
 }
 
 sub prepare_action {
@@ -75,7 +75,6 @@ sub get_session_expires {
 
 sub set_session_expires {
     my ( $c, $expires ) = @_;
-    
     $c->_set_session(expires => time() + $expires);
     $c->maybe::next::method($expires)
 }
@@ -94,10 +93,6 @@ __END__
 
 =pod
 
-=head1 NAME
-
-Catalyst::Plugin::Session::State::Stash - Maintain session IDs using the stash
-
 =head1 SYNOPSIS
 
  use Catalyst qw/Session Session::State::Stash Session::Store::Foo/;
@@ -160,16 +155,16 @@ The name of the hash key to use. Defaults to C<_session>.
 
 =item stash_delim
 
-If present, splits stash_key at this character to nest. E.g. delim of '/'
-and key of '123/456' will store it as $c->stash->{123}->{456}
+If present, splits C<stash_key> at this character to nest. E.g. a C<delim> of '/'
+and C<stash_key> of '123/456' will store it as $c->stash->{123}->{456}
 
 =item expires
-    
+
 How long the session should last in seconds.
 
 =back
 
-For example, you could stick this in MyApp.pm:
+For example, you could stick this in F<MyApp.pm>:
 
   __PACKAGE__->config( 'Plugin::Session' => {
      stash_key  => 'session_id',
@@ -178,15 +173,16 @@ For example, you could stick this in MyApp.pm:
 =head1 BUGS
 
 You can't delete a session then create a new one. If this is important to you,
-patches welcome. It is not important to me and fixing this for completeness
-is pretty low on my list of priorities.
+patches welcome!
 
 =head1 CAVEATS
 
 Manual work may be involved to make better use of this.
 
+=for stopwords stateful
+
 If you are writing a stateful web service with
-L<Catalyst::Plugin::Server::XMLRPC>, you will probably only have to deal with 
+L<Catalyst::Plugin::Server::XMLRPC>, you will probably only have to deal with
 loading, as when saving, the ID will already be on the stash.
 
 =head1 SEE ALSO
@@ -194,23 +190,17 @@ loading, as when saving, the ID will already be on the stash.
 L<Catalyst>, L<Catalyst::Plugin::Session>, L<Catalyst::Plugin::Session::State>,
 L<Catalyst::Plugin::Session::State::Cookie> (what you probably want).
 
-=head1 AUTHORS
-
-James Laver E<lt>perl -e 'printf qw/%s@%s.com cpan jameslaver/'E<gt>
-
 =head1 CONTRIBUTORS
 
-This module is derived from L<Catalyst::Plugin::Session::State::Cookie> code.
+=over 4
 
+=item *
+This module is derived from L<Catalyst::Plugin::Session::State::Cookie> code.
 Thanks to anyone who wrote code for that.
 
+=item *
 Thanks to Kent Fredric for a patch for nested keys
 
-=head1 COPYRIGHT
-
-This program is free software, you can redistribute it and/or modify it
-under the same terms as Perl itself.
+=back
 
 =cut
-
-1;