The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Class::Easy - make class routine easy

ABSTRACT

This module is a functionality compilation of some good modules from CPAN. Ideas are taken from Class::Data::Inheritable, Class::Accessor, Modern::Perl and Moose at least.

At the beginning I planned to create lightweight and feature-less drop-in alternative to Moose. Now package contains tree modules: class accessors, easy logging and timer for easy development.

SYNOPSIS

SYNOPSIS

        use Class::Easy; # automatic loading of strict and warnings
        
        # try to load package IO::Easy, return 1 when success
        try_to_use ('IO::Easy');
        
        # try to load package IO::Easy, but search for package existence
        # within %INC instead of symbolic table
        try_to_use_inc ('IO::Easy');
        
        # for current package
        has "property_ro"; # make readonly object accessor
        has "property_rw", is => 'rw'; # make readwrite object accessor
        
        has "global25", default => 25; # make readonly static accessor with value 25
        has "global", global => 1, is => 'rw'; # make readwrite static accessor

        # make subroutine in package main
        make_accessor ('main', 'initialize', default => sub {
                $::initialized = 1;
                return "initialized!";
        });

        # string "[PID] [PACKAGE(STRING)] [DBG] something" logged
        # only if $Class::Easy::DEBUG = 'immediately';
        debug "something";

        # BEWARE! all timer operations are calculated only
        # when $Class::Easy::DEBUG has true value for
        # easy distinguishing between debug and production

        my $t = timer ('long operation');
        # … long operation

        my $time = $t->lap ('another long op');
        # …

        $time = $t->end;
        # $time contains time between last 'lap' or 'timer'
        # and 'end' call

        $time = $t->total;
        # now $time contains total time between timer init
        # and end call

FUNCTIONS

has ($name [, is => 'ro' | 'rw'] [, default => $default], [, global => 1])

create accessor named $name in current scope

make_accessor ($scope, $name)

create accessor in selected scope

AUTHOR

Ivan Baktsheev, <apla at the-singlers.us>

BUGS

Please report any bugs or feature requests to my email address, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Easy. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008-2009 Ivan Baktsheev

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 284:

Non-ASCII character seen before =encoding in '…'. Assuming UTF-8