Class-Data-Inheritable-0.10/000755 000765 000024 00000000000 14706323460 015713 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/PaxHeader/Changes000644 000765 000024 00000000236 14706323061 021155 xustar00ryanstaff000000 000000 30 mtime=1729734193.114124382 69 LIBARCHIVE.xattr.com.apple.lastuseddate#PS=L6UZZwAAAADqxhwcAAAAAA 59 SCHILY.xattr.com.apple.lastuseddate#PS=/ฅg๊ฦ Class-Data-Inheritable-0.10/Changes000644 000765 000024 00000001773 14706323061 017213 0ustar00ryanstaff000000 000000 0.10 Thu Oct 24 01:40:24 UTC 2024 - don't use vars, use our (thanks haarg) 0.09 Fri Jul 30 22:42:00 UTC 2021 - Update spelling errors to resolve #83824 and #86563 0.08 Sat Jan 26 00:34:11 NZDT 2008 - Fix 'perltooc' typo in Docs 0.07 Sat Jan 26 00:34:11 NZDT 2008 - Relicense as dual AL/GPL 0.06 Wed Sep 20 14:35:55 BST 2006 - Sync the japanese docs (as best as possible!) 0.05 Sat Aug 26 18:27:12 UTC 2006 - Use correct bug reporting address (Jonathan Rockway) 0.04 Sat Sep 24 12:36:56 UTC 2005 - Tony Bowden now maintainer - Document how to set value when creating data - Complete rewrite of tests 0.03 Tue Mar 11 18:30:01 GMT 2003 - Rearranged the docs a smidge. - Added Japanese docs from perldocjp (thanks Atsuhi Kato) - mk_classdata() is now explicitly only a class method - Added this change log. 0.02 Sat Apr 15 05:14:17 GMT 2000 * mk_classdata() now creates a private accessor alias. 0.01 Fri Apr 14 09:17:15 GMT 2000 * First cut. Class-Data-Inheritable-0.10/MANIFEST000644 000765 000024 00000000415 14157310415 017040 0ustar00ryanstaff000000 000000 Changes doc/jp/Class-Data-Inheritable.pod lib/Class/Data/Inheritable.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP META.yml README t/Inheritable.t t/pod-coverage.t t/pod.t META.json Module JSON meta-data (added by MakeMaker) Class-Data-Inheritable-0.10/t/000755 000765 000024 00000000000 14706323460 016156 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/README000644 000765 000024 00000007035 14157736757 016621 0ustar00ryanstaff000000 000000 NAME Class::Data::Inheritable - Inheritable, overridable class data SYNOPSIS package Stuff; use base qw(Class::Data::Inheritable); # Set up DataFile as inheritable class data. Stuff->mk_classdata('DataFile'); # Declare the location of the data file for this class. Stuff->DataFile('/etc/stuff/data'); # Or, all in one shot: Stuff->mk_classdata(DataFile => '/etc/stuff/data'); DESCRIPTION Class::Data::Inheritable is for creating accessor/mutators to class data. That is, if you want to store something about your class as a whole (instead of about a single object). This data is then inherited by your subclasses and can be overridden. For example: Pere::Ubu->mk_classdata('Suitcase'); will generate the method Suitcase() in the class Pere::Ubu. This new method can be used to get and set a piece of class data. Pere::Ubu->Suitcase('Red'); $suitcase = Pere::Ubu->Suitcase; The interesting part happens when a class inherits from Pere::Ubu: package Raygun; use base qw(Pere::Ubu); # Raygun's suitcase is Red. $suitcase = Raygun->Suitcase; Raygun inherits its Suitcase class data from Pere::Ubu. Inheritance of class data works analogous to method inheritance. As long as Raygun does not "override" its inherited class data (by using Suitcase() to set a new value) it will continue to use whatever is set in Pere::Ubu and inherit further changes: # Both Raygun's and Pere::Ubu's suitcases are now Blue Pere::Ubu->Suitcase('Blue'); However, should Raygun decide to set its own Suitcase() it has now "overridden" Pere::Ubu and is on its own, just like if it had overridden a method: # Raygun has an orange suitcase, Pere::Ubu's is still Blue. Raygun->Suitcase('Orange'); Now that Raygun has overridden Pere::Ubu further changes by Pere::Ubu no longer effect Raygun. # Raygun still has an orange suitcase, but Pere::Ubu is using Samsonite. Pere::Ubu->Suitcase('Samsonite'); Methods mk_classdata Class->mk_classdata($data_accessor_name); Class->mk_classdata($data_accessor_name => $value); This is a class method used to declare new class data accessors. A new accessor will be created in the Class using the name from $data_accessor_name, and optionally initially setting it to the given value. To facilitate overriding, mk_classdata creates an alias to the accessor, _field_accessor(). So Suitcase() would have an alias _Suitcase_accessor() that does the exact same thing as Suitcase(). This is useful if you want to alter the behavior of a single accessor yet still get the benefits of inheritable class data. For example. sub Suitcase { my($self) = shift; warn "Fashion tragedy" if @_ and $_[0] eq 'Plaid'; $self->_Suitcase_accessor(@_); } AUTHOR Original code by Damian Conway. Maintained by Michael G Schwern until September 2005. Maintained by Tony Bowden until August 2021 Now maintained by Ryan Sherer BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-Data-Inheritable@rt.cpan.org COPYRIGHT and LICENSE Copyright (c) 2000-2021, Damian Conway, Michael G Schwern, Tony Bowden, and Ryan Sherer. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. SEE ALSO perltootc has a very elaborate discussion of class data in Perl. Class-Data-Inheritable-0.10/MANIFEST.SKIP000644 000765 000024 00000000545 14157310415 017611 0ustar00ryanstaff000000 000000 # Avoid version control files. \bRCS\b \bCVS\b ,v$ ,B$ ,D$ \B\.svn\b aegis.log$ \bconfig$ \bbuild$ # Avoid Makemaker generated and utility files. \bMakefile$ \bblib \bMakeMaker-\d \bpm_to_blib$ \bblibdirs$ # Avoid Module::Build generated and utility files. \bBuild$ \b_build # Avoid temp and backup files. ~$ \.gz$ \.old$ \.bak$ \.swp$ \.tdy$ \#$ \b\.# Class-Data-Inheritable-0.10/META.yml000644 000765 000024 00000001023 14706323460 017160 0ustar00ryanstaff000000 000000 --- abstract: 'Inheritable, overridable class data' author: - unknown build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Class-Data-Inheritable no_index: directory: - t - inc requires: {} version: '0.10' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Class-Data-Inheritable-0.10/lib/000755 000765 000024 00000000000 14706323460 016461 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/Makefile.PL000644 000765 000024 00000000355 14157310415 017664 0ustar00ryanstaff000000 000000 use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Class::Data::Inheritable', VERSION_FROM => "lib/Class/Data/Inheritable.pm", ABSTRACT_FROM => "lib/Class/Data/Inheritable.pm", LICENSE => 'perl', PREREQ_PM => {}, ); Class-Data-Inheritable-0.10/doc/000755 000765 000024 00000000000 14706323460 016460 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/META.json000644 000765 000024 00000001561 14706323460 017337 0ustar00ryanstaff000000 000000 { "abstract" : "Inheritable, overridable class data", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Class-Data-Inheritable", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : {} } }, "release_status" : "stable", "version" : "0.10", "x_serialization_backend" : "JSON::PP version 4.06" } Class-Data-Inheritable-0.10/doc/jp/000755 000765 000024 00000000000 14706323460 017071 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/doc/jp/Class-Data-Inheritable.pod000644 000765 000024 00000012711 14157310415 023733 0ustar00ryanstaff000000 000000 =pod =head1 รŒยพรยฐ Class::Data::Inheritable - ยทร‘ยพยตยฒร„ร‡ยฝยครŠ, ยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰ยฒร„ร‡ยฝยครŠยกยขยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟ =head1 ยณยตรร— package Stuff; use base qw(Class::Data::Inheritable); # DataFileยครฒยกยขยทร‘ยพยตยฒร„ร‡ยฝยครŠยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครˆยคยทยคร†ยฅยปยฅรƒยฅรˆยฅยขยฅรƒยฅร—ยคยนยครซยกยฃ Stuff->mk_classdata('DataFile'); # ยคยณยครŽยฅยฏยฅรฉยฅยนยคยฟยครกยคร‹ยฅร‡ยกยผยฅยฟยฅร•ยฅยกยฅยคยฅรซยครŽยพรฌยฝรชยครฒร€รซยธร€ยคยนยครซยกยฃ Stuff->DataFile('/etc/stuff/data'); Stuff->mk_classdata(DataFile => '/etc/stuff/data'); =head1 ยณยตรร— Class::Data::Inheritable ยครยกยขยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครŽยฅยขยฅยฏยฅยปยฅยต/ยฅรŸยฅรฅยกยผยฅร†ยกยผยฅยฟยครฒยบรฎยครซยครŽยคร‹ยธรพยคยคยคร†ยคยคยครžยคยนยกยฃ ยคร„ยครžยครชยกยข(รƒยฑยฐรฌยครŽยฅยชยฅร–ยฅยธยฅยงยฅยฏยฅรˆยครˆยครยฐรฃยครƒยคร†ยกยข)ยฅยฏยฅรฉยฅยนรยดร‚รŽยคร‹ยฒยฟยคยซยครฒรƒรŸยคยจยคยฟยคยคยพรฌยนรงยคร‡ยคยนยกยฃ ยคยณยครŽยฅร‡ยกยผยฅยฟยครยกยขยฅยตยฅร–ยฅยฏยฅรฉยฅยนยคร‡ยทร‘ยพยตยคยตยครฌร†ร€ยครžยคยนยคยทยกยขยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰ยคยตยครฌร†ร€ยครžยคยนยกยฃ รŽรฃ: Pere::Ubu->mk_classdata('Suitcase'); ยคยณยครฌยครยกยขSuitcate ยฅรกยฅยฝยฅรƒยฅร‰ยครฒยกยขPere::Ubu ยฅยฏยฅรฉยฅยนยคร‹ร€ยธร€ยฎยคยทยครžยคยนยกยฃ ยฟยทยคยทยคยคยฅรกยฅยฝยฅรƒยฅร‰ยครยกยขยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครŽยฐรฌยคร„ยครฒร†ร€ยคยฟยครชยกยขยฅยปยฅรƒยฅรˆยคยนยครซยครŽยคร‹ยกยขยปรˆยครฏยครฌร†ร€ยครžยคยนยกยฃ Pere::Ubu->Suitcase('Red'); $suitcase = Pere::Ubu->Suitcase; รŒรŒร‡รฒยคยคร‰รดรŠยฌยคยฌยกยขยฅยฏยฅรฉยฅยนยคยฌ Pere::Ubu ยคยซยครฉยทร‘ยพยตยคยนยครซยครˆยคยญยคร‹ยตยฏยคยณยครชยครžยคยนยกยง package Raygun; use base qw(Pere::Ubu); # RaygunยครŽยฅยนยกยผยฅร„ยฅยฑยกยผยฅยนยคร Red. $suitcase = Raygun->Suitcase; Raygun ยครยกยขPere::Ubuยคยซยครฉยฅยนยกยผยฅร„ยฅยฑยกยผยฅยนยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยทร‘ยพยตยคยทยครžยคยนยกยฃ ยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครŽยทร‘ยพยตยครยกยขยฅรกยฅยฝยฅรƒยฅร‰ยทร‘ยพยตยคร‹analgousยครฒร†ยฐยคยซยคยทยครžยคยนยกยฃ Raygunยคยฌยกยขยทร‘ยพยตยคยตยครฌยคยฟยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครฒ(Suitcase()ยครฒยปรˆยครƒยคร†ยกยขยฟยทยคยทยคยครƒรยครฒยฅยปยฅรƒยฅรˆยคยนยครซยคยณยครˆยคร‹ยครจยครƒยคร†)"ยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰"ยคยทยครŠยคยคยคยซยคยฎยครชยกยข Pere::Ubu ยคร‡ยกยขยฅยปยฅรƒยฅรˆยคยตยครฌยคยฟยครขยครŽยครฒยครŠยครณยคร‡ยครขยปรˆยคยคร‚ยณยคยฑยกยขยฐรŠรยฐยครŽรŠร‘ยนยนยครฒยทร‘ยพยตยคยทร‚ยณยคยฑยครžยคยนยกยฃ # Raygun ยครˆ Pere::Ubu ยครŽ suitcases ยครยกยขยบยฃยคร Blue ยคร‡ยคยนยกยฃ Pere::Ubu->Suitcase('Blue'); ยคยทยคยซยคยทยกยขRaygun ยคยฌยกยขยผยซรŠยฌยผยซยฟรˆยครŽSuitcase() ยครฒยฅยปยฅรƒยฅรˆยคยนยครซยคร™ยคยญยคร€ยครˆยทรจยครกยครซยครˆยกยข Suitcase() ยครยกยข ยบยฃยครคยกยขPare::Ubu ยครฒ"ยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰"ยคยทยคร†ยคยชยครชยกยขRaygun ยผยซยฟรˆยครŽยครขยครŽยคร‡ยคยนยกยฃ ยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰ยคยตยครฌยคยฟยฅรกยฅยฝยฅรƒยฅร‰ยคร‹ยครยครงยคยฆยคร‰ยกยขยปรทยคร†ยคยคยครžยคยนยกยฃ # Raygun ยคร orange ยครŽยฅยนยกยผยฅร„ยฅยฑยกยผยฅยนยครฒยปรฝยคร„ยคยฌยกยขPere::Ubu ยครŽยฅยนยกยผยฅร„ยฅยฑยกยผยฅยนยครยกยขยครžยคร€ Blue ยคร‡ยคยน. Raygun->Suitcase('Orange'); ยคยตยคร†ยกยขRaygun ยครยกยขPare::Ubu ยครฒยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰ยคยทยคยฟยครŽยคร‡ยกยขPare::Ubu ยคร‹ยครจยครซยกยขยฐรŠรยฐยครŽรŠร‘ยนยนยคร ยครžยครƒยคยฟยคยฏ Raygun ยคร‹ยครยกยขยฑร†ยถรยครฒรยฟยคยจยครžยคยปยครณยกยฃ # Raygun ยครยกยขยครžยคร€ยกยขorange ยครŽยฅยนยกยผยฅร„ยฅยฑยกยผยฅยนยคร‡ยคยนยคยฌยกยข Pere::Ubu ยครยกยขSamsonite ยครฒยปรˆยคยคยครžยคยนยกยฃ Pere::Ubu->Suitcase('Samsonite'); =head1 ยฅรกยฅยฝยฅรƒยฅร‰ =head2 B Class->mk_classdata($data_accessor_name); Class->mk_classdata($data_accessor_name => $value); ยคยณยครฌยครยฅยฏยฅรฉยฅยนยฅรกยฅยฝยฅรƒยฅร‰ยคร‡ยกยขยฟยทยคยทยคยคยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครŽยฅยขยฅยฏยฅยปยฅยตยครฒร€รซยธร€ยคยนยครซยครŽยคร‹ยปรˆยครฏยครฌยครžยคยนยกยฃ $data_accessor_name ยครฒรŒยพรยฐยคร‹ยปรˆยครƒยคร†ยกยขยฟยทยคยทยคยคยฅยขยฅยฏยฅยปยฅยตยคยฌยฅยฏยฅรฉยฅยนร†รขยคร‹ยบรฎยครฉยครฌยครžยคยนยกยฃ ยฅยชยกยผยฅรยกยผยฅรฉยฅยคยฅร‰ยครฒรร†ยฐร—ยคร‹ยคยนยครซยคยฟยครกยคร‹ยกยขmk_classdata ยครยกยขยฅยขยฅยฏยฅยปยฅยตยคร˜ยครŽยฅยจยฅยคยฅรชยฅยขยฅยน _field_accessor() ยครฒยบรฎยครชยครžยคยนยกยฃ ยคยฝยครฌยคร‡ยกยขSuitcase() ยคร‹ยครยกยข_Suitcase_accessor() ยครˆยคยคยคยฆยฅยจยฅยคยฅรชยฅยขยฅยนยคยฌยคยขยครชยกยข ยคยณยครŽยฅยจยฅยคยฅรชยฅยขยฅยนยครยกยขSuitcase() ยครˆยกยขยครยครงยคยฆยคร‰ร†ยฑยคยธยคยณยครˆยครฒยคยทยครžยคยนยกยฃ รƒยฑยฐรฌยครŽยฅยขยฅยฏยฅยปยฅยตยครŽยฟยถยครซร‰รฑยคยคยครฒรŠร‘ยคยจยครจยคยฆยครˆยคยทยคร†ยกยข ยครžยคร€ยกยขยทร‘ยพยตยฒร„ร‡ยฝยครŠยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยครŽยฒยธยทรƒยครฒร†ร€ยคยฟยคยคยครŠยครฉยกยขรยญยฑร—ยคร‡ยคยนยกยฃยผยกยครŽรŽรฃยครŽยครจยคยฆยคร‹ยกยฃ sub Suitcase { my($self) = shift; warn "Fashion tragedy" if @_ and $_[0] eq 'Plaid'; $self->_Suitcase_accessor(@_); } =head1 รƒรธยบรฎยธยข (ยธยถรŠยธยครžยครž) Copyright (c) 2000, Damian Conway and Michael G Schwern. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html) =head1 รƒรธยผร” (ยธยถรŠยธยครžยครž) Original code by Damian Conway. Maintained by Michael G Schwern until September 2005. Now maintained by Tony Bowden. =head1 BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-Data-Inheritable@rt.cpan.org =head1 SEE ALSO L ยครยกยขยครˆยคร†ยครขร†รพร‡ยฐยครŠPerlยครŽยฅยฏยฅรฉยฅยนยฅร‡ยกยผยฅยฟยคร‹ยคร„ยคยคยคร†ยครŽยตร„รร€ยคยฌยคยขยครชยครžยคยนยกยฃ =head1 ร‹รรŒรตยคร‹ยคร„ยคยคยคร† ร‹รรŒรตยผร”ยกยงยฒรƒร†ยฃร†ร˜ (atusi@pure.ne.jp) Perlยฅร‰ยฅยญยฅรฅยฅรกยฅรณยฅรˆร†รผร‹รœยธรฌรŒรต Project ยคร‹ยคร†ยกยข Perlยฅรขยฅยธยฅรฅยกยผยฅรซยกยขยฅร‰ยฅยญยฅรฅยฅรกยฅรณยฅรˆยครŽร‹รรŒรตยครฒยนร”ยครƒยคร†ยคยชยครชยครžยคยนยกยฃ http://sourceforge.jp/projects/perldocjp/ http://freeml.com/ctrl/html/MLInfoForm/perldocjp@freeml.com http://www.perldoc.jp Class-Data-Inheritable-0.10/lib/Class/000755 000765 000024 00000000000 14706323460 017526 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/lib/Class/Data/000755 000765 000024 00000000000 14706323460 020377 5ustar00ryanstaff000000 000000 Class-Data-Inheritable-0.10/lib/Class/Data/Inheritable.pm000644 000765 000024 00000007723 14706321770 023176 0ustar00ryanstaff000000 000000 package Class::Data::Inheritable; use strict qw(vars subs); our $VERSION = '0.10'; sub mk_classdata { my ($declaredclass, $attribute, $data) = @_; if( ref $declaredclass ) { require Carp; Carp::croak("mk_classdata() is a class method, not an object method"); } my $accessor = sub { my $wantclass = ref($_[0]) || $_[0]; return $wantclass->mk_classdata($attribute)->(@_) if @_>1 && $wantclass ne $declaredclass; $data = $_[1] if @_>1; return $data; }; my $alias = "_${attribute}_accessor"; *{$declaredclass.'::'.$attribute} = $accessor; *{$declaredclass.'::'.$alias} = $accessor; } 1; __END__ =head1 NAME Class::Data::Inheritable - Inheritable, overridable class data =head1 SYNOPSIS package Stuff; use base qw(Class::Data::Inheritable); # Set up DataFile as inheritable class data. Stuff->mk_classdata('DataFile'); # Declare the location of the data file for this class. Stuff->DataFile('/etc/stuff/data'); # Or, all in one shot: Stuff->mk_classdata(DataFile => '/etc/stuff/data'); =head1 DESCRIPTION Class::Data::Inheritable is for creating accessor/mutators to class data. That is, if you want to store something about your class as a whole (instead of about a single object). This data is then inherited by your subclasses and can be overridden. For example: Pere::Ubu->mk_classdata('Suitcase'); will generate the method Suitcase() in the class Pere::Ubu. This new method can be used to get and set a piece of class data. Pere::Ubu->Suitcase('Red'); $suitcase = Pere::Ubu->Suitcase; The interesting part happens when a class inherits from Pere::Ubu: package Raygun; use base qw(Pere::Ubu); # Raygun's suitcase is Red. $suitcase = Raygun->Suitcase; Raygun inherits its Suitcase class data from Pere::Ubu. Inheritance of class data works analogous to method inheritance. As long as Raygun does not "override" its inherited class data (by using Suitcase() to set a new value) it will continue to use whatever is set in Pere::Ubu and inherit further changes: # Both Raygun's and Pere::Ubu's suitcases are now Blue Pere::Ubu->Suitcase('Blue'); However, should Raygun decide to set its own Suitcase() it has now "overridden" Pere::Ubu and is on its own, just like if it had overridden a method: # Raygun has an orange suitcase, Pere::Ubu's is still Blue. Raygun->Suitcase('Orange'); Now that Raygun has overridden Pere::Ubu further changes by Pere::Ubu no longer effect Raygun. # Raygun still has an orange suitcase, but Pere::Ubu is using Samsonite. Pere::Ubu->Suitcase('Samsonite'); =head1 Methods =head2 mk_classdata Class->mk_classdata($data_accessor_name); Class->mk_classdata($data_accessor_name => $value); This is a class method used to declare new class data accessors. A new accessor will be created in the Class using the name from $data_accessor_name, and optionally initially setting it to the given value. To facilitate overriding, mk_classdata creates an alias to the accessor, _field_accessor(). So Suitcase() would have an alias _Suitcase_accessor() that does the exact same thing as Suitcase(). This is useful if you want to alter the behavior of a single accessor yet still get the benefits of inheritable class data. For example. sub Suitcase { my($self) = shift; warn "Fashion tragedy" if @_ and $_[0] eq 'Plaid'; $self->_Suitcase_accessor(@_); } =head1 AUTHOR Original code by Damian Conway. Maintained by Michael G Schwern until September 2005. Now maintained by Tony Bowden. =head1 BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-Data-Inheritable@rt.cpan.org =head1 COPYRIGHT and LICENSE Copyright (c) 2000-2005, Damian Conway and Michael G Schwern. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. =head1 SEE ALSO L has a very elaborate discussion of class data in Perl. Class-Data-Inheritable-0.10/t/pod.t000644 000765 000024 00000000201 14157310415 017112 0ustar00ryanstaff000000 000000 use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Class-Data-Inheritable-0.10/t/Inheritable.t000644 000765 000024 00000002503 14157310415 020565 0ustar00ryanstaff000000 000000 use strict; use Test::More tests => 15; package Ray; use base qw(Class::Data::Inheritable); Ray->mk_classdata('Ubu'); Ray->mk_classdata(DataFile => '/etc/stuff/data'); package Gun; use base qw(Ray); Gun->Ubu('Pere'); package Suitcase; use base qw(Gun); Suitcase->DataFile('/etc/otherstuff/data'); package main; foreach my $class (qw/Ray Gun Suitcase/) { can_ok $class => qw/mk_classdata Ubu _Ubu_accessor DataFile _DataFile_accessor/; } # Test that superclasses effect children. is +Gun->Ubu, 'Pere', 'Ubu in Gun'; is +Suitcase->Ubu, 'Pere', "Inherited into children"; is +Ray->Ubu, undef, "But not set in parent"; # Set value with data is +Ray->DataFile, '/etc/stuff/data', "Ray datafile"; is +Gun->DataFile, '/etc/stuff/data', "Inherited into gun"; is +Suitcase->DataFile, '/etc/otherstuff/data', "Different in suitcase"; # Now set the parent ok +Ray->DataFile('/tmp/stuff'), "Set data in parent"; is +Ray->DataFile, '/tmp/stuff', " - it sticks"; is +Gun->DataFile, '/tmp/stuff', "filters down to unchanged children"; is +Suitcase->DataFile, '/etc/otherstuff/data', "but not to changed"; my $obj = bless {}, 'Gun'; eval { $obj->mk_classdata('Ubu') }; ok $@ =~ /^mk_classdata\(\) is a class method, not an object method/, "Can't create classdata for an object"; is $obj->DataFile, "/tmp/stuff", "But objects can access the data"; Class-Data-Inheritable-0.10/t/pod-coverage.t000644 000765 000024 00000000241 14157310415 020707 0ustar00ryanstaff000000 000000 use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok();