r607 - in packages/libclass-default-perl/branches/upstream/1.1: . inc/Module inc/Module/Install lib/Class t
Allard Hoeve
hoeve-guest@costa.debian.org
Mon, 10 Jan 2005 20:18:40 +0100
Author: hoeve-guest
Date: 2005-01-10 20:18:39 +0100 (Mon, 10 Jan 2005)
New Revision: 607
Modified:
packages/libclass-default-perl/branches/upstream/1.1/Build.PL
packages/libclass-default-perl/branches/upstream/1.1/Changes
packages/libclass-default-perl/branches/upstream/1.1/LICENSE
packages/libclass-default-perl/branches/upstream/1.1/MANIFEST
packages/libclass-default-perl/branches/upstream/1.1/META.yml
packages/libclass-default-perl/branches/upstream/1.1/Makefile.PL
packages/libclass-default-perl/branches/upstream/1.1/README
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/AutoInstall.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Base.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Build.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Can.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Fetch.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Makefile.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Metadata.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Win32.pm
packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/WriteAll.pm
packages/libclass-default-perl/branches/upstream/1.1/lib/Class/Default.pm
packages/libclass-default-perl/branches/upstream/1.1/t/00_compile.t
packages/libclass-default-perl/branches/upstream/1.1/t/01_main.t
Log:
Repatch 1.0 -> 1.1, this time, do the whitespace correctly
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/Build.PL
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/Changes
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/LICENSE
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/MANIFEST
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/META.yml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/Makefile.PL
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: packages/libclass-default-perl/branches/upstream/1.1/README
===================================================================
--- packages/libclass-default-perl/branches/upstream/1.1/README 2005-01-10 19:15:49 UTC (rev 606)
+++ packages/libclass-default-perl/branches/upstream/1.1/README 2005-01-10 19:18:39 UTC (rev 607)
@@ -2,26 +2,26 @@
Class::Default - Static calls apply to a default instantiation
SYNOPSIS
- # Create the defaulted class
- package Foo::Base;
-
- use base 'Class::Default';
-
- sub new { bless {}, $_[0] }
-
- sub show {
- my $self = shift->_self;
- "$self";
- }
-
- # Do something to the default object
-
- package main;
-
- print Foo::Bar->show;
-
- # Prints 'Foo::Bar=HASH(0x80d22f8)'
-
+ # Create the defaulted class
+ package Foo::Base;
+
+ use base 'Class::Default';
+
+ sub new { bless {}, $_[0] }
+
+ sub show {
+ my $self = shift->_self;
+ "$self";
+ }
+
+ # Do something to the default object
+
+ package main;
+
+ print Foo::Bar->show;
+
+ # Prints 'Foo::Bar=HASH(0x80d22f8)'
+
DESCRIPTION
Class::Default provides a mechanism to allow your class to take static
method calls and apply it to a default instantiation of an object. It
@@ -58,21 +58,21 @@
A typical method will look something like the following
- sub foobar {
- my $self = shift;
-
- # Do whatever the method does
- }
-
+ sub foobar {
+ my $self = shift;
+
+ # Do whatever the method does
+ }
+
To make the method work with Class::Default, you should change it to the
following
- sub foobar {
- my $self = shift->_self;
-
- # Do whatever the method does
- }
-
+ sub foobar {
+ my $self = shift->_self;
+
+ # Do whatever the method does
+ }
+
This change is very low impact, easy to use, and will not make any other
differences to the way your code works.
@@ -93,42 +93,42 @@
demonstrate the use of "_create_default_object" to set some values in
the default object.
- package Slashdot::User;
-
- use base 'Class::Default';
-
- # Constructor
- sub new {
- my $class = shift;
- my $name = shift;
-
- my $self = {
- name => $name,
- favourite_color => '',
- };
-
- return bless $self, $class;
- }
-
- # Default constructor
- sub _create_default_object {
- my $class = shift;
-
- my $self = $class->new( 'Anonymous Coward' );
- $self->{favourite_color} = 'Orange';
-
- return $self;
- }
-
- sub name { $_[0]->{name} }
- sub favourite_color { $_[0]->{favourite_color} }
-
+ package Slashdot::User;
+
+ use base 'Class::Default';
+
+ # Constructor
+ sub new {
+ my $class = shift;
+ my $name = shift;
+
+ my $self = {
+ name => $name,
+ favourite_color => '',
+ };
+
+ return bless $self, $class;
+ }
+
+ # Default constructor
+ sub _create_default_object {
+ my $class = shift;
+
+ my $self = $class->new( 'Anonymous Coward' );
+ $self->{favourite_color} = 'Orange';
+
+ return $self;
+ }
+
+ sub name { $_[0]->{name} }
+ sub favourite_color { $_[0]->{favourite_color} }
+
That provides a statically accessible default object that could be used
as in the following manner.
- print "The default slashdot user is " . Slashdot::User->name
- . " and they like the colour " . Slashdot::User->favourite_color;
-
+ print "The default slashdot user is " . Slashdot::User->name
+ . " and they like the colour " . Slashdot::User->favourite_color;
+
Remember that the default object is persistant, so changes made to the
statically accessible object can be recovered later.
@@ -136,8 +136,8 @@
There are a few ways to do this, but the easiest way is to simple do the
following
- my $default = Slashdot::User->_get_default;
-
+ my $default = Slashdot::User->_get_default;
+
METHODS
_self
Used by methods to make the method apply to the default object if called
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/README
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/AutoInstall.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Base.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Build.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Can.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Fetch.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Makefile.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Metadata.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/Win32.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install/WriteAll.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/inc/Module/Install.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: packages/libclass-default-perl/branches/upstream/1.1/lib/Class/Default.pm
===================================================================
--- packages/libclass-default-perl/branches/upstream/1.1/lib/Class/Default.pm 2005-01-10 19:15:49 UTC (rev 606)
+++ packages/libclass-default-perl/branches/upstream/1.1/lib/Class/Default.pm 2005-01-10 19:18:39 UTC (rev 607)
@@ -5,14 +5,14 @@
# See POD for more details.
-require 5.005;
+use 5.005;
use strict;
-use Carp;
+use Carp ();
# Define globals
use vars qw{$VERSION %DEFAULT};
BEGIN {
- $VERSION = '1.0';
+ $VERSION = '1.1';
# Create the default object storage.
%DEFAULT = ();
@@ -24,7 +24,7 @@
ref($either) ? $either
: $DEFAULT{$either}
|| ($DEFAULT{$either} = $either->_create_default_object)
- || croak "Error while creating default object";
+ || Carp::croak "Error while creating default object";
}
# Suplimentary method to reliably get ONLY the class
@@ -36,7 +36,7 @@
my $class = shift;
$DEFAULT{$class}
|| ($DEFAULT{$class} = $class->_create_default_object)
- || croak "Error while creating default object";
+ || Carp::croak "Error while creating default object";
}
# Creates the default object.
@@ -238,18 +238,16 @@
=head1 SUPPORT
+Bugs should be reported via the CPAN bug tracker at
+
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class%3ADefault>
+
Contact the author
=head1 AUTHOR
- Adam Kennedy
- cpan@ali.as
- http://ali.as/
+Adam Kennedy (Maintainer), L<http://ali.as/>, cpan@ali.as
-=head1 SEE ALSO
-
-Class::*
-
=head1 COPYRIGHT
Copyright (c) 2002 Adam Kennedy. All rights reserved.
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/lib/Class/Default.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/t/00_compile.t
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: packages/libclass-default-perl/branches/upstream/1.1/t/01_main.t
___________________________________________________________________
Name: svn:eol-style
+ native