You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/02/03 23:20:39 UTC
[lucy-commits] svn commit: r1067007 - in /incubator/lucy/trunk/clownfish/lib/Clownfish:
Parcel.pm Symbol.pm
Author: marvin
Date: Thu Feb 3 22:20:38 2011
New Revision: 1067007
URL: http://svn.apache.org/viewvc?rev=1067007&view=rev
Log:
Finish cleaning out Clownfish::Symbol. Add Clownfish::Parcel->acquire() to
derive a Parcel from different kinds of input.
Modified:
incubator/lucy/trunk/clownfish/lib/Clownfish/Parcel.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Symbol.pm
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Parcel.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Parcel.pm?rev=1067007&r1=1067006&r2=1067007&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Parcel.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Parcel.pm Thu Feb 3 22:20:38 2011
@@ -20,6 +20,7 @@ package Clownfish::Parcel;
use base qw( Exporter );
use Clownfish;
use Clownfish::Util qw( verify_args );
+use Scalar::Util qw( blessed );
use Carp;
our %singleton_PARAMS = (
@@ -34,6 +35,21 @@ sub singleton {
return $package->_singleton( @args{qw( name cnick )} );
}
+sub acquire {
+ my ( undef, $thing ) = @_;
+ if ( !defined $thing ) {
+ return Clownfish::Parcel->default_parcel;
+ }
+ elsif ( blessed($thing) ) {
+ confess("Not a Clownfish::Parcel")
+ unless $thing->isa('Clownfish::Parcel');
+ return $thing;
+ }
+ else {
+ return Clownfish::Parcel->singleton( name => $thing );
+ }
+}
+
1;
__END__
@@ -96,6 +112,14 @@ Return the singleton for default parcel,
Return one of the three capitalization variants for the parcel's prefix.
+=head2 acquire
+
+ $parcel = Clownfish::Parcel->aquire($parcel_name_or_parcel_object);
+
+Aquire a parcel one way or another. If the supplied argument is a Parcel,
+return it. If it's not defined, return the default Parcel. If it's a name,
+invoke singleton().
+
=head2 get_name get_cnick
Accessors.
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Symbol.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Symbol.pm?rev=1067007&r1=1067006&r2=1067007&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Symbol.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Symbol.pm Thu Feb 3 22:20:38 2011
@@ -19,8 +19,7 @@ use warnings;
package Clownfish::Symbol;
use Clownfish;
use Clownfish::Parcel;
-use Clownfish::Util qw( a_isa_b verify_args );
-use Scalar::Util qw( blessed );
+use Clownfish::Util qw( verify_args );
use Carp;
my %new_PARAMS = (
@@ -31,34 +30,13 @@ my %new_PARAMS = (
micro_sym => undef,
);
-my $struct_regex = qr/[A-Z]+[A-Z0-9]*[a-z]+[A-Za-z0-9]*/;
-my $class_name_regex = qr/^$struct_regex(::$struct_regex)*$/;
-
sub new {
my ( $either, %args ) = @_;
verify_args( \%new_PARAMS, %args ) or confess $@;
- my $class_name = delete $args{class_name};
- my $class_cnick = delete $args{class_cnick};
- my $micro_sym = delete $args{micro_sym};
- my $parcel = delete $args{parcel};
- my $exposure = delete $args{exposure};
-
- # Acquire a Parcel.
- if ( !defined $parcel ) {
- $parcel = Clownfish::Parcel->default_parcel;
- }
- elsif ( blessed($parcel) ) {
- confess("Not a Clownfish::Parcel")
- unless $parcel->isa('Clownfish::Parcel');
- }
- else {
- $parcel = Clownfish::Parcel->singleton( name => $parcel );
- }
-
- # Create the object.
+ $args{parcel} = Clownfish::Parcel->acquire( $args{parcel} );
my $class_class = ref($either) || $either;
- return $class_class->_new( $parcel, $exposure, $class_name, $class_cnick,
- $micro_sym );
+ return $class_class->_new(
+ @args{qw( parcel exposure class_name class_cnick micro_sym )} );
}
1;