Class::Meta::Declare

Class::Meta::Declare is a Perl module deprecated in favor of Class::Meta::Express.
Download

Class::Meta::Declare Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Curtis Poe
  • Publisher web site:
  • http://search.cpan.org/~ovid/

Class::Meta::Declare Tags


Class::Meta::Declare Description

Class::Meta::Declare is a Perl module deprecated in favor of Class::Meta::Express. Class::Meta::Declare is a Perl module deprecated in favor of Class::Meta::Express.SYNOPSISThis was a first attempt at making a saner interface for Class::Meta. It is nicer, but Class::Meta::Express is nicer still. Go use that one. package MyApp::Thingy; use Class::Meta::Declare ':all'; use Data::UUID; Class::Meta::Declare->new( meta => , attributes => , methods => ; }, } ] ); my $object = MyApp::Thingy->new; print MyApp::Thingy->pi; # prints 3.1415927 print $object->name; # prints "No Name Supplied'; $object->set_name("bob"); print $object->name; # prints "bob"This class provides an alternate interface for Class::Meta.Class::Meta is a useful module which allows one to create Perl classes which support introspection (also known as reflection). Typically Perl classes, when created, don't supply a lot of metadata. Imported helper functions show up when you call $object->can($method). Private, protected and trusted methods are not readily supported. Fetching a list of attributes or methods is a haphazard affair. Class::Meta overcomes these shortcomings by building the classes for you and allowing you to fetch a class object: my $class_object = $object->my_class; foreach my $attribute ( $class_object->attributes ) { print $attribute->name, "n"; } foreach my $method ( $class_object->methods ) { print $method->name, "n"; }If you've set up your class correctly, these properties are now easy to discover.Unfortunately, many find the Class::Meta interface to be a bit clumsy. As an alternative, Class::Meta::Declare allows you to declare your entire class in a single argument list to the constructor and have the class built for you automatically. Further, reasonable defaults are provided for just about everything.IMPORTANT: You want this class or Class::Meta if you need an introspection API for your classes. If you do not need introspection or dynamic class generation, these modules are overkill. Requirements: · Perl


Class::Meta::Declare Related Software