Class-MakeMethods
view release on metacpan or search on metacpan
MakeMethods/Emulator/MethodMaker.pm view on Meta::CPAN
use Class::MakeMethods::Emulator::MethodMaker '-take_namespace';
use Class::MethodMaker (
new_with_init => 'new',
get_set => [ qw / foo bar baz / ];
);
=head1 DESCRIPTION
This module provides emulation of Class::MethodMaker, using the Class::MakeMethods framework.
Although originally based on Class::MethodMaker, the calling convention
for Class::MakeMethods differs in a variety of ways; most notably, the names
given to various types of methods have been changed, and the format for
specifying method attributes has been standardized. This package uses
the aliasing capability provided by Class::MakeMethods, defining methods
that modify the declaration arguments as necessary and pass them off to
various subclasses of Class::MakeMethods.
=head1 COMPATIBILITY
Full compatibility is maintained with version 1.03; some of the
changes in versions 1.04 through 1.10 are not yet included.
The test suite from Class::MethodMaker version 1.10 is included
with this package, in the t/emulator_class_methodmaker/ directory.
The unsupported tests have names ending in ".todo".
The tests are unchanged from those in the Class::MethodMaker
distribution, except for the substitution of
C<Class::MakeMethods::Emulator::MethodMaker> in the place of
C<Class::MethodMaker>.
In cases where earlier distributions of Class::MethodMaker contained
a different version of a test, it is also included. (Note that
version 0.92's get_concat returned '' for empty values, but in
version 0.96 this was changed to undef; this emulator follows the
later behavior. To avoid "use of undefined value" warnings from
the 0.92 version of get_concat.t, that test has been modified by
appending a new flag after the name, C<'get_concat --noundef'>,
which restores the earlier behavior.)
=head1 USAGE
There are several ways to call this emulation module:
=over 4
=item *
Direct Access
Replace occurances in your code of C<Class::MethodMaker> with C<Class::MakeMethods::Emulator::MethodMaker>.
=item *
Install Emulation
If you C<use Class::MakeMethods::Emulator::MethodMaker '-take_namespace'>, the Class::MethodMaker namespace will be aliased to this package, and calls to the original package will be transparently handled by this emulator.
To remove the emulation aliasing, call C<use Class::MakeMethods::Emulator::MethodMaker '-release_namespace'>.
B<Note:> This affects B<all> subsequent uses of Class::MethodMaker in your program, including those in other modules, and might cause unexpected effects.
=item *
The -sugar Option
Passing '-sugar' as the first argument in a use or import call will cause the 'methods' package to be declared as an alias to this one.
This allows you to write declarations in the following manner.
use Class::MakeMethods::Emulator::MethodMaker '-sugar';
make methods
get_set => [ qw / foo bar baz / ],
list => [ qw / a b c / ];
B<Note:> This feature is deprecated in Class::MethodMaker version 0.96 and later.
=back
=cut
my $emulation_target = 'Class::MethodMaker';
sub import {
my $mm_class = shift;
if ( scalar @_ and $_[0] =~ /^-take_namespace/ and shift ) {
Class::MakeMethods::Emulator::namespace_capture(__PACKAGE__, $emulation_target);
} elsif ( scalar @_ and $_[0] =~ /^-release_namespace/ and shift ) {
Class::MakeMethods::Emulator::namespace_release(__PACKAGE__, $emulation_target);
}
if ( scalar @_ and $_[0] eq '-sugar' and shift ) {
Class::MakeMethods::Emulator::namespace_capture(__PACKAGE__, "methods");
}
$mm_class->make( @_ ) if ( scalar @_ );
}
=head1 METHOD CATALOG
B<NOTE:> The documentation below is derived from version 1.02 of
Class::MethodMaker. Class::MakeMethods::Emulator::MethodMaker
provides support for all of the features and examples shown below,
with no changes required.
=head1 CONSTRUCTOR METHODS
=head2 new
Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'.
=cut
( run in 1.042 second using v1.01-cache-2.11-cpan-39bf76dae61 )