[Moose-commits] r7464 -
MooseX-Params-Validate/trunk/lib/MooseX/Params
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Sun Feb 1 15:08:44 GMT 2009
Author: autarch
Date: 2009-02-01 07:08:44 -0800 (Sun, 01 Feb 2009)
New Revision: 7464
Modified:
MooseX-Params-Validate/trunk/lib/MooseX/Params/Validate.pm
Log:
Move cache key getting to its own sub
Modified: MooseX-Params-Validate/trunk/lib/MooseX/Params/Validate.pm
===================================================================
--- MooseX-Params-Validate/trunk/lib/MooseX/Params/Validate.pm 2009-02-01 12:57:33 UTC (rev 7463)
+++ MooseX-Params-Validate/trunk/lib/MooseX/Params/Validate.pm 2009-02-01 15:08:44 UTC (rev 7464)
@@ -24,14 +24,7 @@
sub validated_hash {
my ( $args, %spec ) = @_;
- my $cache_key;
- if ( exists $spec{MX_PARAMS_VALIDATE_CACHE_KEY} ) {
- $cache_key = $spec{MX_PARAMS_VALIDATE_CACHE_KEY};
- delete $spec{MX_PARAMS_VALIDATE_CACHE_KEY};
- }
- else {
- $cache_key = ( caller(1) )[3];
- }
+ my $cache_key = _cache_key( \%spec );
if ( exists $CACHED_SPECS{$cache_key} ) {
( ref $CACHED_SPECS{$cache_key} eq 'HASH' )
@@ -73,13 +66,7 @@
my %spec = @spec;
- my $cache_key;
- if ( exists $spec{MX_PARAMS_VALIDATE_CACHE_KEY} ) {
- $cache_key = delete $spec{MX_PARAMS_VALIDATE_CACHE_KEY};
- }
- else {
- $cache_key = ( caller(1) )[3];
- }
+ my $cache_key = _cache_key( \%spec );
my @ordered_spec;
if ( exists $CACHED_SPECS{$cache_key} ) {
@@ -123,6 +110,17 @@
*validatep = \&validated_list;
+sub _cache_key {
+ my $spec = shift;
+
+ if ( exists $spec->{MX_PARAMS_VALIDATE_CACHE_KEY} ) {
+ return delete $spec->{MX_PARAMS_VALIDATE_CACHE_KEY};
+ }
+ else {
+ return ( caller(2) )[3];
+ }
+}
+
sub _convert_to_param_validate_spec {
my ($spec) = @_;
my %pv_spec;
More information about the Moose-commits
mailing list