/usr/share/perl5/Exporter/Declare/Export/Generator.pm is in libexporter-declare-perl 0.114-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | package Exporter::Declare::Export::Generator;
use strict;
use warnings;
use base 'Exporter::Declare::Export::Sub';
use Exporter::Declare::Export::Variable;
use Carp qw/croak/;
sub required_specs {
my $self = shift;
return(
$self->SUPER::required_specs(),
qw/ type /,
);
}
sub type { shift->_data->{ type }}
sub new {
my $class = shift;
croak "Generators must be coderefs, not " . ref($_[0])
unless ref( $_[0] ) eq 'CODE';
$class->SUPER::new( @_ );
}
sub generate {
my $self = shift;
my ( $import_class, @args ) = @_;
my $ref = $self->( $self->exported_by, $import_class, @args );
return Exporter::Declare::Export::Sub->new(
$ref,
%{ $self->_data },
) if $self->type eq 'sub';
return Exporter::Declare::Export::Variable->new(
$ref,
%{ $self->_data },
) if $self->type eq 'variable';
return $self->type->new(
$ref,
%{ $self->_data },
);
}
sub inject {
my $self = shift;
my ( $class, $name, @args ) = @_;
$self->generate( $class, @args )->inject( $class, $name );
}
1;
=head1 NAME
Exporter::Declare::Export::Generator - Export class for exports that should be
generated when imported.
=head1 DESCRIPTION
Export class for exports that should be generated when imported.
=head1 OVERRIDEN METHODS
=over 4
=item $class->new( $ref, $ref, exported_by => $package, type => $type, %data )
You must specify the type as 'sub' or 'variable'.
=item $export->inject( $package, $name, @args )
Calls generate() with @args to create a generated export. The new export is
then injected.
=back
=head1 ADDITIONAL METHODS
=over 4
=item $new = $export->generate( $import_class, @args )
Generates a new export object.
=item $type = $export->type()
Returns the type of object to be generated (sub or variable)
=back
=head1 AUTHORS
Chad Granum L<exodist7@gmail.com>
=head1 COPYRIGHT
Copyright (C) 2010 Chad Granum
Exporter-Declare is free software; Standard perl licence.
Exporter-Declare is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
|