Class::Meta::Express
Details
| Size: | 8K |
| Last Update: | 2008-05-17 01:33:04 |
| Version: | 0.04 |
| OS Support: | Linux |
| License/Program Type: | Perl Artistic License |
| Publisher: | David Wheeler |
| Price: | $0.00 |
Description:
Class::Meta::Express 0.04 is libraries software developed by David Wheeler.
Class::Meta::Express is a Perl module for concise, expressive creation of Class::Meta classes.
Synopsis
package My::Contact;
use Class::Meta::Express;
class {
meta contact => ( default_type => 'string' );
has 'name';
has contact => ( required => 1 );
}
This module provides an interface to concisely yet expressively create classes with Class::Meta. Although I am of course fond of Class::Meta, I've never been overly thrilled with its interface for creating classes:
package My::Thingy;
use Class::Meta;
BEGIN {
Create a Class::Meta object for this class.
my $cm = Class::Meta->new( key => 'thingy' );
Add a constructor.
$cm->add_constructor( name => 'new' );
Add a couple of attributes with generated accessors.
$cm->add_attribute(
name => 'id',
is => 'integer',
required => 1,
);
$cm->add_attribute(
name => 'name',
is => 'string',
required => 1,
);
$cm->add_attribute(
name => 'age',
is => 'integer',
);
Add a custom method.
$cm->add_method(
name => 'chk_pass',
code => sub { return 'code' },
);
$cm->build;
}
This example is relatively simple; it can get a lot more verbose. But even still, all of the method calls were annoying. I mean, whoever thought of using an object oriented interface for declaring a class? (Oh yeah: I did.) I wasn't alone in wanting a more declarative interface; Curtis Poe, with my blessing, created Class::Meta::Declare, which would use this syntax to create the same class:
package My::Thingy;
use Class::Meta::Declare ':all';
Class::Meta::Declare->new(
Create a Class::Meta object for this class.
meta => [
key => 'thingy',
],
Add a constructor.
constructors => [
new => { }
],
Add a couple of attributes with generated accessors.
attributes => [
id => {
type => $TYPE_INTEGER,
required => 1,
},
name => {
required => 1,
type => $TYPE_STRING,
},
age => { type => $TYPE_INTEGER, },
],
Add a custom method.
methods => [
chk_pass => {
code => sub { return 'code' },
}
]
);
This approach has the advantage of being a bit more concise, and it is declarative, but I find all of the indentation levels annoying; it's hard for me to figure out where I am, especially if I have to define a lot of attributes. And finally, everything is a string with this syntax, except for those ugly read-only scalars such as $TYPE_INTEGER. So I can't easily tell where one attribute ends and the next one starts. Bleh.
Requirements:
Perl
Class::Meta::Express 0.04 supports english interface languages and works with Linux.
Downloading Class::Meta::Express 0.04 will take several seconds if you use fast ADSL connection.
0 comments
Add to
Class::Meta::Express Version History
Related Software
|
|
From category: Libraries |
| Chart::Graph 3.2 is libraries software developed by CAIDA Perl development team. Chart::Graph is a Perl extension for a front-end to gnuplot, XRT, and Xmgrace. SYNOPSIS EXAMPLE: gn... |
|
|
From category: Libraries |
| Bundle::OS2_default 1.07 is libraries software developed by Bundle::OS2_default Team. Bundle::OS2_default are Perl modules to install last for OS/2 binary distribution. SYNOPSIS per... |
|
|
From category: Libraries |
| FXPy 1.0.5 is libraries software developed by Lyle Johnson. FXPy is a Python extension module which provides an interface to the FOX cross-platform GUI library. The FXPy API follows the sta... |
|
|
From category: Libraries |
| DBD::ODBC::Changes 1.13 is libraries software developed by DBD::ODBC::Changes Team. DBD::ODBC::Changes is a Perl module with logs of significant changes to the DBD::ODBC. Requirements: P... |
|
|
From category: Libraries |
| HTTP client request class is a PHP class that implements requests to Web resources using the HTTP protocol.... |
|
|
From category: Libraries |
| Algorithm::C3 0.05 is libraries software developed by Stevan Little and Brandon L. Black. Algorithm::C3 is a module for merging hierarchies using the C3 algorithm. SYNOPSIS use Algo... |
|
|
From category: Perl-Modules |
| Net::Peep::Conf is a Perl extension for providing an object representation of configuration information for Peep.... |
|
|
From category: Libraries |
| C++ XML Objects 1.0.0.7 is libraries software developed by Paul Hamilton. C++ XML Objects is a framework for persisting hierarchies of C++ objects to and from XML. Boost, The STL and Patterns are u... |
|
|
From category: Compilers |
| The Blue Programming Language project is a unique bytecode-compiled language.... |
|
|
From category: Libraries |
| DateTime::Format::Excel 0.2901 is libraries software developed by Iain Truskett. DateTime::Format::Excel is a Perl module that can convert between DateTime and Excel dates. SYNOPSIS... |
|
|
From category: Libraries |
| Big Faceless Report Generator 1.1.32 is libraries software developed by Big Faceless Organization. Big Faceless Report Generator project is a Java application for converting source documents writte... |
|
|
From category: Code-Generators |
| C to C++ 1.4.0 is code generators software developed by Denis G. Sureau. C to C++ is a Python script that converts C code to C++ code. The main program is ctocpp.py that performs successive... |
|
|
From category: Compilers |
| bksys 1.5.1 is compilers software developed by Thomas Nagy. bksys is a framework based on scons for detecting the environment, compiling applications and installing them. It replaces the who... |
|
|
From category: Libraries |
| Audio::MPD 0.12.3 is libraries software developed by Tue Abrahamsen. Audio::MPD is a class for talking to MPD (Music Player Daemon) servers. SYNOPSIS use Audio::MPD; my $mp... |
|
|
From category: Libraries |
| Code::Perl 0.03 is libraries software developed by Fergal Daly. Code::Perl is a Perl module to produce Perl code from a tree. SYNOPSIS use Code::Perl::Expr qw( :easy ); my... |
Leave a comment