Skip to content

Commit

Permalink
Changed the separator from '/' to '::'.
Browse files Browse the repository at this point in the history
Changed the separator from '/' to '::'.
Fixed a portability issue on Win32.
Changed from DynaLoader to XSLoader
  • Loading branch information
Leont committed Mar 22, 2010
1 parent 19f6e89 commit a96e4cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class-Private

This module provides some level of encapsulation around hashrefs for objects. It does this by transforming every C<key> into C<package/key>. This way you won't have collisions. If the key contains a C</>, it will not be transformed, and normal access takes place. Thus keys from other packages can be accessed explicitly if necessary.
This module provides some level of encapsulation around hashrefs for objects. It does this by transforming every C<key> into C<package::key>. This way you won't have collisions. If the key contains C<::>, it will not be transformed, and normal access takes place. Thus keys from other packages can be accessed explicitly if necessary.

INSTALLATION

Expand Down
12 changes: 6 additions & 6 deletions lib/Class/Private.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package Class::Private;
use 5.010;
use strict;
use warnings;
use base 'DynaLoader';
use XSLoader;

our $VERSION = '0.02';
our $VERSION = '0.03';

bootstrap Class::Private $VERSION;
XSLoader::load('Class::Private', $VERSION);

1; # End of Class::Private

Expand All @@ -19,7 +19,7 @@ Class::Private - Private hashes for your objects
=head1 VERSION
Version 0.02
Version 0.03
=head1 SYNOPSIS
Expand All @@ -40,11 +40,11 @@ Version 0.02
$object->{foo} = 'quz';
# This will
$object->{'Your::Class/foo'} = 'quz';
$object->{'Your::Class::foo'} = 'quz';
=head1 DESCRIPTION
This module provides some level of encapsulation around hashrefs for objects. It does this by transforming every C<key> into C<package/key>. This way you won't have collisions. If the key contains a C</>, it will not be transformed, and normal access takes place. Thus keys from other packages can be accessed explicitly if necessary.
This module provides some level of encapsulation around hashrefs for objects. It does this by transforming every C<key> into C<package::key>. This way you won't have collisions. If the key contains C<::>, it will not be transformed, and normal access takes place. Thus keys from other packages can be accessed explicitly if necessary.
=head1 METHODS
Expand Down
4 changes: 2 additions & 2 deletions lib/Class/Private.xs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

I32 hash_name_filter(pTHX_ IV action, SV* val) {
MAGIC* magic = mg_find(val, PERL_MAGIC_uvar);
if (index(SvPV_nolen(magic->mg_obj), '/') == NULL)
magic->mg_obj = sv_2mortal(newSVpvf("%s/%s", CopSTASHPV(PL_curcop), SvPV_nolen(magic->mg_obj)));
if (strstr(SvPV_nolen(magic->mg_obj), "::") == NULL)
magic->mg_obj = sv_2mortal(newSVpvf("%s::%s", CopSTASHPV(PL_curcop), SvPV_nolen(magic->mg_obj)));
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion t/10-basics.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ $foo->{bar} = 2;
package main;

is($foo->{bar}, 1, '$foo->{bar} should be 1 in main');
is($foo->{'Bar/bar'}, 2, '$foo->{\'Bar/bar\'} should be 2');
is($foo->{'Bar::bar'}, 2, '$foo->{\'Bar::bar\'} should be 2');

0 comments on commit a96e4cd

Please sign in to comment.