Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Object::Declare 0.13

    Download button

    No screenshots available
    Downloads: 317  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Audrey Tang | More programs
    Perl Artistic License / FREE
    October 18th, 2006, 12:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    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 ['MyApp::Column', 'MyApp::Param'];

    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 object

    This 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 => ['declare'], # 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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    declarative object | object constructor | Perl module | Object::Declare | declarative | object

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM