Class::MakeMethods::Standard::Universal - Generic Methods
package MyObject; use Class::MakeMethods::Standard::Hash ( no_op => 'this', abstract => 'that', delegate => { name=>'play_music', target=>'instrument', method=>'play' }, );
The Standard::Universal suclass of MakeMethods provides a [INCOMPLETE].
When you use this package, the method names you provide as arguments cause subroutines to be generated and installed in your module.
use
See "Calling Conventions" in Class::MakeMethods::Standard for more information.
To declare methods, pass in pairs of a method-type name followed by one or more method names.
Valid method-type names for this package are listed in "METHOD GENERATOR TYPES".
See "Declaration Syntax" in Class::MakeMethods::Standard and "Parameter Syntax" in Class::MakeMethods::Standard for more information.
For each method name passed, returns a subroutine with the following characteristics:
Does nothing.
You might want to create and use such methods to provide hooks for subclass activity.
Sample declaration and usage:
package MyObject; use Class::MakeMethods::Standard::Universal ( no_op => 'whatever', ); ... # Doesn't do anything MyObject->whatever();
Fails with an error message.
This is intended to support the use of abstract methods, that must be overidden in a useful subclass.
If each subclass is expected to provide an implementation of a given method, using this abstract method will replace the generic error message below with the clearer, more explicit error message that follows it:
Can't locate object method "foo" via package "My::Subclass" The "foo" method is abstract and can not be called on My::Subclass
However, note that the existence of this method will be detected by UNIVERSAL::can(), so it is not suitable for use in optional interfaces, for which you may wish to be able to detect whether the method is supported or not.
package MyObject; use Class::MakeMethods::Standard::Universal ( abstract => 'whatever', ); ... package MySubclass; sub whatever { ... } # Failure MyObject->whatever(); # Success MySubclass->whatever();
Calls .
You might want to create and use such methods to allow easy initialization of multiple object or class parameters in a single call.
Note: including methods of this type will circumvent the protection of private and protected methods.
package MyObject; use Class::MakeMethods::Standard::Universal ( call_methods => 'init', ); ... # Success MySubclass->new()->init( foo => 'Foozle', bar => 'Barbados' );
Has a list of other methods names as an arrayref in the 'methods' parameter. Required.
When called, calls each of the named method on itself, in order, and returns the concatenation of their results.
If a 'join' parameter is provided it is included between each method result.
If the 'skip_blanks' parameter is omitted, or is provided with a true value, removes all undefined or empty-string values from the results.
Calls a method on self to retrieve another object, and then calls a method on that object and returns its value.
You might want to create and use such methods to faciliate composition of objects from smaller objects.
package MyObject; use Class::MakeMethods::Standard::Universal ( 'Standard::Hash:object' => { name=>'instrument' }, delegate => { name=>'play_music', target=>'instrument', method=>'play' } ); ... # Failure my $object = MyObject->new(); $object->instrument( MyInstrument->new ); $object->play_music;
See Class::MakeMethods and Class::MakeMethods::Standard for an overview of the method-generation framework this is based on.
See Class::MakeMethods::ReadMe for distribution, installation, version and support information.
To install Class::MakeMethods, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::MakeMethods
CPAN shell
perl -MCPAN -e shell install Class::MakeMethods
For more information on module installation, please visit the detailed CPAN module installation guide.