Rose::Object::MakeMethodsRose::Object::MakeMethods is a simple method maker base Perl class. | |
Download |
Rose::Object::MakeMethods Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- John C. Siracusa
- Publisher web site:
- http://search.cpan.org/~jsiracusa/
Rose::Object::MakeMethods Tags
Rose::Object::MakeMethods Description
Rose::Object::MakeMethods is a simple method maker base Perl class. Rose::Object::MakeMethods is a simple method maker base Perl class.SYNOPSIS package MyMethodMaker; use Rose::Object::MakeMethods; our @ISA = qw(Rose::Object::MakeMethods); sub widget { my($class, $name, $args) = @_; my $key = $args->{'hash_key'} || $name; my $interface = $args->{'interface'} || 'get_set'; my %methods; if($interface =~ /^get_set/) { $methods{$name} = sub { my($self) = shift; if(@_) { ... } ... return $self->{$key}; }; } if($interface eq 'get_set_delete') { $methods{"delete_$name"} = sub { ... }; ) return %methods; } ... package MyObject; sub new { ... } use MyMethodMaker ( 'widget --get_set_delete' => 'foo', 'widget' => ); ... $o = MyObject->new; $o->foo($bar); $o->delete_foo(); print $o->bar . $o->baz; ...Rose::Object::MakeMethods is the base class for a family of method makers. A method maker is a module that's used to define methods in other packages. The actual method makers are subclasses of Rose::Object::MakeMethods that define the names and options of the different kinds of methods that they can make.There are method makers that make both object methods and class methods. The object method makers are in the Rose::Object::MakeMethods::* namespace. The class method makers are in the Rose::Class::MakeMethods::* namespace for the sake of clarity, but still inherit from Class::MethodMaker and therefore share the same method making interface.Several useful method makers are included under the Rose::Object::MakeMethods::* and Rose::Class::MakeMethods::* namespaces, mostly for use by other Rose::* objects and classes.This family of modules is not as powerful or flexible as the one that inspired it: Class::MethodMaker. I found that I was only using a tiny corner of the functionality provided by Class::MethodMaker, so I wrote this as a simple, smaller replacement.The fact that many Rose::* modules use Rose::Object::MakeMethods subclasses to make their methods should be considered an implementation detail that can change at any time. Requirements: · Perl
Rose::Object::MakeMethods Related Software