[Rt-devel] Re: [PATCH] DBIx::SB::Record.pm aliases cleanup and docs [ver2]

Ruslan U. Zakirov Ruslan.Zakirov at miet.ru
Wed May 11 06:39:45 EDT 2005


Jesse Vincent wrote:
> 
>>Attach two solutions and three patches. Just for fun! :)
>>
>>1) via capitalization.pm 0.03
>>nocap_via_pragma.patch
>>This patch has docs that should be added in any case.
> 
> 
> What do you think of doing this one, but with a "soft requirement" -- so
> that if the user doesn't have capitalization.pm, the module still runs,
> just inly in "CamelCase" mode?
> 
No problems, here it is. Added feature to Makefile.PL, but looks like it 
works nice only when auto_install is turned on :(

If you want to add tests for nocap API then I can send you patch.

-
Regards, Ruslan.
-------------- next part --------------
==== Patch <-> level 1
Source: [No source]
Target: fac90757-c5f0-0310-a953-bfb799f65e4e:/DBIx-SearchBuilder/local:242
Log:
no cap via optional pragma
=== Makefile.PL
==================================================================
--- Makefile.PL  (revision 242)
+++ Makefile.PL  (patch - level 1)
@@ -7,8 +7,15 @@
 requires('Want');
 requires('Encode');
 requires('Class::ReturnValue', 0.40);
-requires( 'Cache::Simple::TimedExpiry' => '0.21');
+requires('Cache::Simple::TimedExpiry' => '0.21');
 build_requires('Test::More');
 
+features(
+	'Lower case API' => [
+		-defaults => 0,
+		'capitalization' => '0.03',
+	],
+);
+
 &Makefile->write;
 &Meta->write;
=== SearchBuilder/Record.pm
==================================================================
--- SearchBuilder/Record.pm  (revision 242)
+++ SearchBuilder/Record.pm  (patch - level 1)
@@ -8,6 +8,7 @@
 use Class::ReturnValue;
 
 
+
 # {{{ Doc
 
 =head1 NAME
@@ -337,6 +338,10 @@
 ever else I think of.
 
 
+=head1 METHODS NAMING
+ 
+All methods has lower case aliases, '_' is used to distinguish words.
+For example method C<_PrimaryKeys> has alias C<_primary_keys>.
 
 =head1 METHODS
 
@@ -375,9 +380,9 @@
 =cut
 
 
-*Id = \&id;
 
-sub id  {
+
+sub Id  {
     my $pkey = $_[0]->_PrimaryKey();
     $_[0]->{'values'}->{$pkey};
 }
@@ -394,7 +399,7 @@
 
 
 
-*primary_keys = \&PrimaryKeys;
+
 sub PrimaryKeys { 
     my $self = shift; 
     my %hash = map { $_ => $self->{'values'}->{$_} } @{$self->_PrimaryKeys};
@@ -501,7 +506,7 @@
 
 =cut
 
-*_accessible = \&_Accessible;
+
 sub _Accessible {
     my $self = shift;
     my $attr = shift;
@@ -614,7 +619,7 @@
 
 =cut
 
-*__value = \&__Value;
+
 sub __Value {
   my $self = shift;
   my $field = lc(shift);
@@ -642,7 +647,7 @@
 
 =cut
 
-*_value = \&_Value;
+
 sub _Value  {
   my $self = shift;
   return ($self->__Value(@_));
@@ -660,7 +665,7 @@
 
 =cut
 
-*_set = \&_Set;
+
 sub _Set {
     my $self = shift;
     return ($self->__Set(@_));
@@ -668,7 +673,7 @@
 
 
 
-*__set = \&__Set;
+
 sub __Set {
     my $self = shift;
 
@@ -789,7 +794,7 @@
 
 #TODO: Implement _Validate.
 
-*_validate = \&_Validate;
+
 sub _Validate  {
     my $self = shift;
     my $field = shift;
@@ -926,7 +931,7 @@
 =cut
 
 
-*load = \&Load;
+
 sub Load  {
     my $self = shift;
     # my ($package, $filename, $line) = caller;
@@ -944,8 +949,8 @@
 
 =cut
 
-*load_by_col = \&LoadByCol;
 
+
 sub LoadByCol  {
     my $self = shift;
     my $col = shift;
@@ -970,7 +975,7 @@
 
 =cut
 
-*load_by_cols = \&LoadByCols;
+
 sub LoadByCols  {
     my $self = shift;
     my %hash  = (@_);
@@ -1013,7 +1018,7 @@
 
 =cut
 
-*load_by_id = \&LoadById;
+
 sub LoadById  {
     my $self = shift;
     my $id = shift;
@@ -1034,8 +1039,8 @@
 
 =cut
 
-*load_by_primary_keys = \&LoadByPrimaryKeys;
 
+
 sub LoadByPrimaryKeys {
     my ($self, $data) = @_;
 
@@ -1063,8 +1068,8 @@
 
 =cut
 
-*load_from_hash = \&LoadFromHash;
 
+
 sub LoadFromHash {
   my $self = shift;
   my $hashref = shift;
@@ -1087,9 +1092,9 @@
 
 =cut
 
-*load_from_sql = \&LoadFromSQL;
 
 
+
 sub _LoadFromSQL {
     my $self        = shift;
     my $QueryString = shift;
@@ -1143,8 +1148,8 @@
 
 =cut 
 
-*create = \&Create;
 
+
 sub Create {
     my $self    = shift;
     my %attribs = @_;
@@ -1229,8 +1234,8 @@
 
 =cut
 
-*table = \&Table;
 
+
 sub Table {
     my $self = shift;
     if (@_) {
@@ -1249,7 +1254,7 @@
 
 =cut
 
-*_handle = \&_Handle;
+
 sub _Handle  {
     my $self = shift;
     if (@_) {
@@ -1260,6 +1265,9 @@
 
 # }}}
 
+if( eval { require capitalization } ) {
+	capitalization->unimport( __PACKAGE__ );
+}
 
 1;
 
=== SearchBuilder.pm
==================================================================
--- SearchBuilder.pm  (revision 242)
+++ SearchBuilder.pm  (patch - level 1)
@@ -31,6 +31,11 @@
 
 This module provides an object-oriented mechanism for retrieving and updating data in a DBI-accesible database. 
 
+=head1 METHODS NAMING
+ 
+All methods has lower case aliases, '_' is used to distinguish words.
+For example method C<RedoSearch> has alias C<redo_search>.
+
 =head1 METHODS
 
 =cut
@@ -397,8 +402,8 @@
 
 =cut
 
-*next = \&Next;
 
+
 sub Next {
     my $self = shift;
     my @row;
@@ -430,7 +435,7 @@
 
 =cut
 
-*goto_first_item = \&GotoFirstItem;
+
 sub GotoFirstItem {
     my $self = shift;
     $self->GotoItem(0);
@@ -1341,7 +1346,7 @@
 =cut
 
 
-*count = \&Count;
+
 sub Count {
     my $self = shift;
 
@@ -1603,8 +1608,10 @@
 
 
 # }}}
+if( eval { require capitalization } ) {
+	capitalization->unimport( __PACKAGE__ );
+}
 
-
 1;
 __END__
 

==== BEGIN SVK PATCH BLOCK ====
Version: svk 1.0_01 (linux)

eJyFlF1sFFUUx290drddKyb4gUqCKw6WmG47M3dmdqbAZguUUmibpgVRGt3cmXunHZnuLLOztchg
PLNsLQJBYhMfIPHBxDdNfKGmiYYYMUQa8cGoiQ8EjUEh8cEXX4h4d1cSSgwk8zB3zvmfOed3zzk7
gj2b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6EhSsLSkfihk4dBiI8+hZa651AaLlZRffr8AILTma/3oY93wU9twg0tCf880H5jbV2Y
fzAJV55JweLOkXhu89HkX/hEYv4AoHhrXB9rIu3KdBY7J6tud5rNEo6UP7eJljZm7se0SQRbWDFt
Q6OKYes6B0xMy6KKZKqWokvYaW4aRY9KPh/qcmbGJRm/3Jhc4mXKAZmcbrDN5vNKJCpKawHvae7k
3t69JXeGBRXibdAjvrHLJJziYxewGX6oVl0qKlrUs33r4Gx25aB6vk281oCKWI8cYptSTstlbc2R
shKWpSwxNZy1HCtnmo6uMZX9C7DNE+g=
==== END SVK PATCH BLOCK ====


More information about the Rt-devel mailing list