Class-Mite

 view release on metacpan or  search on metacpan

lib/Class.pm  view on Meta::CPAN

    }

    return 0;
}

sub import {
    my ($class, @args) = @_;
    my $caller = caller;

    # Enable strict and warnings
    strict->import;
    warnings->import;

    # Load Role.pm if exists
    eval { require Role };
    if (!$@) {
        no strict 'refs';
        *{"${caller}::with"} = \&Role::with;
        *{"${caller}::does"} = \&Role::does;
    }

lib/Class/More.pm  view on Meta::CPAN

    return $ACCESSOR_CACHE{$attr_name} ||= sub {
        $_[0]{$attr_name} = $_[1] if @_ > 1;
        return $_[0]{$attr_name};
    };
}

sub import {
    my ($class, @args) = @_;
    my $caller = caller;

    strict->import;
    warnings->import;

    no strict 'refs';

    # Install optimised new method
    *{"${caller}::new"} = _generate_optimised_constructor($caller);

    # Install has method
    *{"${caller}::has"} = \&_has;

lib/Role.pm  view on Meta::CPAN


    if (@args == 0) {
        $REQUIRED_METHODS{$caller} = [];
        *{"${caller}::requires"} = \&requires;
        *{"${caller}::excludes"} = \&excludes;
        *{"${caller}::has"} = \&_role_has;
    } else {
        _setup_role_application($caller, @args);
    }

    strict->import;
    warnings->import;
    _export_with($caller);
}

sub with {
    my (@roles) = @_;
    my $caller = caller;

    # Called inside a ROLE
    if ($IS_ROLE{$caller}) {



( run in 1.311 second using v1.01-cache-2.11-cpan-71847e10f99 )