From bcbf441e09fb502cf64924ff2530fa144bdf52c5 Mon Sep 17 00:00:00 2001 From: Andreas Brachold Date: Mon, 13 Aug 2007 18:41:27 +0000 Subject: * Move files to trunk --- lib/Class/MakeMethods/Template/Class.pm | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 lib/Class/MakeMethods/Template/Class.pm (limited to 'lib/Class/MakeMethods/Template/Class.pm') diff --git a/lib/Class/MakeMethods/Template/Class.pm b/lib/Class/MakeMethods/Template/Class.pm new file mode 100644 index 0000000..c846709 --- /dev/null +++ b/lib/Class/MakeMethods/Template/Class.pm @@ -0,0 +1,103 @@ +package Class::MakeMethods::Template::Class; + +use Class::MakeMethods::Template::Generic '-isasubclass'; + +$VERSION = 1.008; +use strict; +require 5.0; +use Carp; + +=head1 NAME + +Class::MakeMethods::Template::Class - Associate information with a package + +=head1 SYNOPSIS + + package MyObject; + use Class::MakeMethods::Template::Class ( + scalar => [ 'foo' ] + ); + + package main; + + MyObject->foo('bar') + print MyObject->foo(); + +=head1 DESCRIPTION + +These meta-methods provide access to class-specific values. They are similar to Static, except that each subclass has separate values. + +=cut + +sub generic { + { + '-import' => { + 'Template::Generic:generic' => '*' + }, + 'modifier' => { + }, + 'code_expr' => { + '_VALUE_' => '_ATTR_{data}->{_SELF_CLASS_}', + }, + } +} + +######################################################################## + +=head2 Class:scalar + +Creates methods to handle a scalar variable in the declaring package. + +See the documentation on C for interfaces and behaviors. + +=cut + +######################################################################## + +=head2 Class:array + +Creates methods to handle a array variable in the declaring package. + +See the documentation on C for interfaces and behaviors. + +=cut + +sub array { + { + '-import' => { + 'Template::Generic:array' => '*', + }, + 'modifier' => { + '-all' => q{ _REF_VALUE_ or @{_ATTR_{data}->{_SELF_CLASS_}} = (); * }, + }, + 'code_expr' => { + '_VALUE_' => '\@{_ATTR_{data}->{_SELF_CLASS_}}', + }, + } +} + +######################################################################## + +=head2 Class:hash + +Creates methods to handle a hash variable in the declaring package. + +See the documentation on C for interfaces and behaviors. + +=cut + +sub hash { + { + '-import' => { + 'Template::Generic:hash' => '*', + }, + 'modifier' => { + '-all' => q{ _REF_VALUE_ or %{_ATTR_{data}->{_SELF_CLASS_}} = (); * }, + }, + 'code_expr' => { + '_VALUE_' => '\%{_ATTR_{data}->{_SELF_CLASS_}}', + }, + } +} + +1; -- cgit v1.2.3