[Catalyst-commits] r13161 - in Catalyst-Plugin-Params-Nested: . trunk trunk/lib/Catalyst/Plugin/Params trunk/lib/Catalyst/Plugin/Params/Nested

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Wed Apr 14 21:44:58 GMT 2010


Author: t0m
Date: 2010-04-14 22:44:58 +0100 (Wed, 14 Apr 2010)
New Revision: 13161

Added:
   Catalyst-Plugin-Params-Nested/tags/
   Catalyst-Plugin-Params-Nested/trunk/Makefile.PL
   Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested/
   Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested/Expander.pm
Removed:
   Catalyst-Plugin-Params-Nested/trunk/Build.PL
Modified:
   Catalyst-Plugin-Params-Nested/trunk/
   Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm
Log:
Update


Property changes on: Catalyst-Plugin-Params-Nested/trunk
___________________________________________________________________
Added: svn:ignore
   + *.old
META.yml
inc
Makefile
README
blib
pm_to_blib



Deleted: Catalyst-Plugin-Params-Nested/trunk/Build.PL
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/Build.PL	2010-04-14 21:33:15 UTC (rev 13160)
+++ Catalyst-Plugin-Params-Nested/trunk/Build.PL	2010-04-14 21:44:58 UTC (rev 13161)
@@ -1,18 +0,0 @@
-use strict;
-use Module::Build;
-
-my $build = Module::Build->new(
-    create_makefile_pl => 'traditional',
-    license            => 'perl',
-    module_name        => 'Catalyst::Plugin::Params::Nested',
-    requires           => {
-        'perl'             => '5.8.1',
-        'Catalyst'         => '5.49',
-        'Test::MockObject' => '1.01',
-        'CGI::Expand'      => '1.06',
-    },
-    create_readme => 1,
-    sign          => 1,
-);
-$build->create_build_script;
-

Copied: Catalyst-Plugin-Params-Nested/trunk/Makefile.PL (from rev 13160, Catalyst-Plugin-Params-Nested/trunk/Build.PL)
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/Makefile.PL	                        (rev 0)
+++ Catalyst-Plugin-Params-Nested/trunk/Makefile.PL	2010-04-14 21:44:58 UTC (rev 13161)
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+use inc::Module::Install 0.91;
+
+name 'Catalyst-Plugin-Params-Nested';
+all_from 'lib/Catalyst/Plugin/Params/Nested.pm';
+license 'perl';
+
+if ($Module::Install::AUTHOR) {
+    system("pod2text lib/Catalyst/Plugin/Params/Nested.pm > README")
+        and die $!;
+}
+
+requires 'Catalyst'         => '5.49';
+test_requires 'Test::MockObject' => '1.01';
+requires 'CGI::Expand'      => '1.06';
+requires 'MRO::Compat';
+
+resources 'repository' => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Plugin-Params-Nested';
+
+WriteAll();
+

Added: Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested/Expander.pm
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested/Expander.pm	                        (rev 0)
+++ Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested/Expander.pm	2010-04-14 21:44:58 UTC (rev 13161)
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+package Catalyst::Plugin::Params::Nested::Expander;
+use base qw/CGI::Expand/;
+
+use strict;
+use warnings;
+
+sub split_name {
+    my ( $class, $name ) = @_;
+
+    if ( $name =~ /^ \w+ \[/x ) {
+        return grep { defined } ( $name =~ /
+            ^  (\w+)      # root param
+          | \[ (\w+) \] # nested
+        /gx );
+    } else {
+        return $class->SUPER::split_name( $name );
+    }
+}
+
+
+__PACKAGE__;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Catalyst::Plugin::Params::Nested::Expander - CGI::Expand subclass with rails
+like tokenization.
+
+=cut
+

Modified: Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm	2010-04-14 21:33:15 UTC (rev 13160)
+++ Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm	2010-04-14 21:44:58 UTC (rev 13161)
@@ -1,19 +1,18 @@
 #!/usr/bin/perl
-	my ( $self, $c ) = @_;
-
 package Catalyst::Plugin::Params::Nested;
 
 use strict;
 use warnings;
+use 5.8.1;
 
-use NEXT;
+use MRO::Compat;
 use Catalyst::Plugin::Params::Nested::Expander ();
 
-our $VERSION = "0.02";
+our $VERSION = "0.03";
 
 sub prepare_parameters {
     my $c = shift;
-    my $ret = $c->NEXT::prepare_parameters( @_ );
+    my $ret = $c->maybe::next::method( @_ );
 
     my $params = $c->req->params;
 
@@ -25,10 +24,6 @@
     $ret;
 }
 
-sub nested_param {
-    my ( $self, @path ) = @_;
-}
-
 __PACKAGE__;
 
 __END__
@@ -51,10 +46,10 @@
         <input name="foo.gorch" ... />
     </form>
 
-    # turns params into hashrefs: 
+    # turns params into hashrefs:
 
     $c->req->param('foo')->{bar};
-       
+
     $c->req->params({
         # extra params
         foo => {
@@ -66,7 +61,7 @@
         'foo[bar]' => ...,
         'foo.gorch' => ...,
     });
-    
+
 =head1 DESCRIPTION
 
 Ruby on Rails has a nice feature to create nested parameters that help with
@@ -90,8 +85,8 @@
 
 =back
 
-When reading query parameters from C<< $c->req >> you can now access the all the items starting 
-with "foo" as one entity using C<< $c->req->param('foo'); >>. Each subitem, denoted by 
+When reading query parameters from C<< $c->req >> you can now access the all the items starting
+with "foo" as one entity using C<< $c->req->param('foo'); >>. Each subitem, denoted by
 either the dot or the square brackets, will be returned as a further deeper hashref.
 
 =head1 INTERNAL METHODS




More information about the Catalyst-commits mailing list