Class::constr

Class::constr is a Pragma created to implement constructor methods.
Download

Class::constr Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Domizio Demichelis
  • Publisher web site:
  • http://search.cpan.org/~domizio/CGI-Application-Plus-1.21/lib/CGI/Application/CheckRM.pm

Class::constr Tags


Class::constr Description

Class::constr is a Pragma created to implement constructor methods. Class::constr is a Pragma created to implement constructor methods.SYNOPSISClass package MyClass ; # implement constructor without options use Class::constr ; # with all the possible options use Class::constr { name => 'new_object' , pre_process => &change_input, default => { propA => 'something' }, init => , copy => 1 no_strict => 1 } ; # init1 and init2 will be called at run-timeUsage # creates a new object and eventually validates # the properties if any validation property option is set my $object = MyClass->new(digits => '123');This pragma easily implements constructor methods for your class, which are very efficient function templates that your modules may imports at compile time. "This technique saves on both compile time and memory use, and is less error-prone as well, since syntax checks happen at compile time." (quoted from "Function Templates" in the perlref manpage).Use it with Class::props and Object::props to automatically validate the input passed with new(), or use the no_strict option to accept unknown properties as well.You can completely avoid to write the constructor mehtod by just using this pragma and eventually declaring the name and the init methods to call. Requirements: · Perl


Class::constr Related Software