Object::Declare

Object::Declare is a Perl module for declarative object constructor.
Download

Object::Declare Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Audrey Tang
  • Publisher web site:
  • http://search.cpan.org/~adamk/Module-Install-0.68/lib/Module/Install/PAR.pm

Object::Declare Tags


Object::Declare Description

Object::Declare is a Perl module for declarative object constructor. Object::Declare is a Perl module for declarative object constructor.SYNOPSIS use Object::Declare ; my %objects = declare { param foo => !is global, is immutable, valid_values are qw( more values ); column bar => field1 is 'value', field2 is 'some_other_value'; }; print $objects{foo}; # a MyApp::Param object print $objects{bar}; # a MyApp::Column objectThis module exports one function, declare, for building named objects with a declarative syntax, similar to how Jifty::DBI::Schema defines its columns.In list context, declare returns a list of name/object pairs in the order of declaration (allowing duplicates), suitable for putting into a hash. In scalar context, declare returns a hash reference.Using a flexible import interface, one can change exported helper functions names (declarator), words to link labels and values together (copula), and the table of named classes to declare (mapping): use Object::Declare declarator => , # list of declarators copula => { # list of words, or a map is => '', # from copula to prefixes for are => '', # labels built with that copula } aliases => { # list of label aliases: more => 'less', # turns "is more" into "is less" # and "more is 1" into "less is 1" }, mapping => { column => 'MyApp::Column', # class name to call ->new to param => sub { # arbitrary coderef also works bless(@_, 'MyApp::Param'); }, };After the declarator block finishes execution, all helper functions are removed from the package. Same-named functions (such as &is and &are) that existed before the declarator's execution are restored correctly. Requirements: · Perl


Object::Declare Related Software