Acme-Teddy

 view release on metacpan or  search on metacpan

lib/Acme/Teddy.pm  view on Meta::CPAN


    {
        package Frobnitz::Blowhard;
        sub foo{ return 'foo' . shift };
    }
    print Frobnitz::Blowhard::foo('bar');

Although you may find it slightly more convenient, the main purpose of 
Acme::Teddy is to give you the comfort of using a "real" module. 

=head1 FUNCTIONS/METHODS

=head2 import()

This is a cut-down copy of L<Exporter::Heavy>::heavy_export() 
(the same routine that B<Exporter> uses normally to export stuff on request). 

There are two reasons we don't say C<@ISA = qw(Exporter);>. We don't want to 
introduce any dependencies whatsoever; and we offer caller the freedom to 
export anything at all. Almost no checking is done of arguments passed 
to C<import()> (normally, on the C<use()> line).

=head2 new()

    my $bear    = $class->new($ref, @args);

This is a flexible, robust, subclassable object constructor. 

    my $bear    = Acme::Teddy->new();
    my $bear    = Acme::Teddy->new( [] );
    my $bear    = Acme::Teddy->new( \&my_sub );
    my $bear    = Acme::Teddy->new( { -a  => 'x' } );
    my $bear    = Acme::Teddy->new( [ 1, 2, 3, 4 ] );
    my $bear    = Acme::Teddy->new( {}, @some_data );

It will bless any reference. If invoked with C<$class> only, 
blesses an empty hashref and calls L</init()> with no arguments. 

If invoked with C<$class> and a reference,
blesses the reference and calls L</init()> with any remaining C<@args>. 

=head2 init()

This is a placeholder method. You might want to override it in a subclass. 
For common initializations, you can just invoke L</new()> with initial data. 

=head1 INTERFACE 

    {
        package Acme::Teddy;
        # Your target code here.
    }
    package main;
    use Acme::Teddy;
    use Test::Your::Testing::Module;
    # Your test here. 

Start a test script with a bare block in AT (or subclass it). Then define 
whatever behavior you like. After you switch into "your own" package, test 
for that behavior. You should be able to verify by eye that your expectations 
are correct; therefore, you can concentrate on debugging your testing module. 

Writing the bare block is just like writing a module, except that much of the 
dull work is done for you. 

Lexical declarations will "leak" across package boundaries if you leave off 
the bare block; so don't do that. It does not seem to be necessary to make 
this a C<BEGIN> block; if you find any counterexample, please contact author. 

Import whatever you like when you C<use Acme::Teddy>. 
Be sure to define it, whatever it is. 
AT will attempt to export to caller I<everything> you request. 

You don't have to import anything. 
You can invoke a function (that you defined) with: 

    my $return  = Acme::Teddy::my_button_nose();

Or invoke a method: 

    $bear->talk();

Don't forget to define that method! 

=head1 DIAGNOSTICS

=over

=item $pkg: Can't export symbol: $type$sym

You tried to import something bizarre. Check your C<use()> line. 

Rationally, you can only export I<symbols> from one package to another. 
These can be barewords, which will be interpreted as subroutines; 
scalar, array, or hash variables; coderefs; or typeglobs. 

=back 

=head1 CONFIGURATION AND ENVIRONMENT

Acme::Teddy requires no configuration files or environment variables.

=head1 DEPENDENCIES

No dependencies. 

=head1 INCOMPATIBILITIES

None.

=head1 BUGS AND LIMITATIONS

You really do have to define stuff yourself or it does nothing. 

Lexical variables aren't found in package symbol tables. 

=head1 THANKS

=over

=item *



( run in 2.026 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )