summaryrefslogtreecommitdiff
path: root/lib/Class/MakeMethods/Attribute.pm
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-11-10 17:53:53 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-11-10 17:53:53 +0000
commitcfdd733c17cfa4f1a43b827a656e9e53cc2524ac (patch)
treeb6f659b1281f77628b36768f0888f67b65f9ca48 /lib/Class/MakeMethods/Attribute.pm
parent9c6c30350161efd74faa3c3705096aecb71c0e81 (diff)
downloadxxv-cfdd733c17cfa4f1a43b827a656e9e53cc2524ac.tar.gz
xxv-cfdd733c17cfa4f1a43b827a656e9e53cc2524ac.tar.bz2
* Remove unsed packages
* Reorder exit routines
Diffstat (limited to 'lib/Class/MakeMethods/Attribute.pm')
-rw-r--r--lib/Class/MakeMethods/Attribute.pm143
1 files changed, 0 insertions, 143 deletions
diff --git a/lib/Class/MakeMethods/Attribute.pm b/lib/Class/MakeMethods/Attribute.pm
deleted file mode 100644
index b8fe71d..0000000
--- a/lib/Class/MakeMethods/Attribute.pm
+++ /dev/null
@@ -1,143 +0,0 @@
-package Class::MakeMethods::Attribute;
-
-require 5.006;
-use strict;
-use Carp;
-use Attribute::Handlers;
-
-use Class::MakeMethods;
-use Class::MakeMethods::Utility::Inheritable 'get_vvalue';
-
-our $VERSION = 1.005;
-
-our %DefaultMaker;
-
-sub import {
- my $class = shift;
-
- if ( scalar @_ and $_[0] =~ m/^\d/ ) {
- Class::MakeMethods::_import_version( $class, shift );
- }
-
- if ( scalar @_ == 1 ) {
- my $target_class = ( caller(0) )[0];
- $DefaultMaker{ $target_class } = shift;
- }
-}
-
-sub UNIVERSAL::MakeMethod :ATTR(CODE) {
- my ($package, $symbol, $referent, $attr, $data) = @_;
- if ( $symbol eq 'ANON' or $symbol eq 'LEXICAL' ) {
- croak "Can't apply MakeMethod attribute to $symbol declaration."
- }
- if ( ! $data ) {
- croak "No method type provided for MakeMethod attribute."
- }
- my $symname = *{$symbol}{NAME};
- if ( ref $data eq 'ARRAY' ) {
- local $_ = shift @$data;
- $symname = [ @$data, $symname ];
- $data = $_;
- }
- unless ( $DefaultMaker{$package} ) {
- local $_ = get_vvalue( \%DefaultMaker, $package );
- $DefaultMaker{$package} = $_ if ( $_ );
- }
- Class::MakeMethods->make(
- -TargetClass => $package,
- -ForceInstall => 1,
- ( $DefaultMaker{$package} ? ('-MakerClass'=>$DefaultMaker{$package}) : () ),
- $data => $symname
- );
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Class::MakeMethods::Attribute - Declare generated subs with attribute syntax
-
-=head1 SYNOPSIS
-
- package MyObject;
- use Class::MakeMethods::Attribute 'Standard::Hash';
-
- sub new :MakeMethod('new');
- sub foo :MakeMethod('scalar');
- sub bar :MakeMethod('scalar', { hashkey => 'bar_data' });
- sub debug :MakeMethod('Standard::Global:scalar');
-
-=head1 DESCRIPTION
-
-This package allows common types of methods to be generated via a subroutine attribute declaration. (Available in Perl 5.6 and later.)
-
-Adding the :MakeMethod() attribute to a subroutine declaration causes Class::MakeMethods to create and install a subroutine based on the parameters given to the :MakeMethod attribute.
-
-You can declare a default method-generation class by passing the name of a MakeMethods subclass in the use Class::MakeMethods::Attribute statement. This default method-generation class will also apply as the default to any subclasses declared at compile time. If no default method-generation class is selected, you will need to fully-qualify all method type declarations.
-
-=head1 EXAMPLE
-
-Here's a typical use of Class::MakeMethods::Attribute:
-
- package MyObject;
- use Class::MakeMethods::Attribute 'Standard::Hash';
-
- sub new :MakeMethod('new');
- sub foo :MakeMethod('scalar');
- sub bar :MakeMethod('scalar', { hashkey => 'bar_data' });
- sub debug :MakeMethod('Standard::Global:scalar');
-
- package MySubclass;
- use base 'MyObject';
-
- sub bazzle :MakeMethod('scalar');
-
-This is equivalent to the following explicit Class::MakeMethods invocations:
-
- package MyObject;
-
- use Class::MakeMethods (
- -MakerClass => 'Standard::Hash',
- new => 'new',
- scalar => 'foo',
- scalar => [ 'ba', { hashkey => 'bar_data' } ],
- 'Standard::Global:scalar' => 'debug',
- );
-
- package MySubclass;
- use base 'MyObject';
-
- use Class::MakeMethods (
- -MakerClass => 'Standard::Hash',
- scalar => 'bazzle',
- );
-
-=head1 DIAGNOSTICS
-
-The following warnings and errors may be produced when using
-Class::MakeMethods::Attribute to generate methods. (Note that this
-list does not include run-time messages produced by calling the
-generated methods, or the standard messages produced by
-Class::MakeMethods.)
-
-=over
-
-=item Can't apply MakeMethod attribute to %s declaration.
-
-You can not use the C<:MakeMethod> attribute with lexical or anonymous subroutine declarations.
-
-=item No method type provided for MakeMethod attribute.
-
-You called C<:MakeMethod()> without the required method-type argument.
-
-=back
-
-=head1 SEE ALSO
-
-See L<Attribute::Handlers> byÊDamian Conway.
-
-See L<Class::MakeMethods> for general information about this distribution.
-
-=cut