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::MOP::Immutable - A class to transform Class::MOP::Class metaclasses

SYNOPSIS

    use Class::MOP::Immutable;
    
    my $immutable_metaclass = Class::MOP::Immutable->new($metaclass, {
        read_only   => [qw/superclasses/],
        cannot_call => [qw/
            add_method
            alias_method
            remove_method
            add_attribute
            remove_attribute
            add_package_symbol
            remove_package_symbol            
        /],
        memoize     => {
            class_precedence_list             => 'ARRAY',
            compute_all_applicable_attributes => 'ARRAY',            
            get_meta_instance                 => 'SCALAR',     
            get_method_map                    => 'SCALAR',     
        }
    });   

    $immutable_metaclass->make_metaclass_immutable(@_)

DESCRIPTION

This is basically a module for applying a transformation on a given metaclass. Current features include making methods read-only, making methods un-callable and memoizing methods (in a type specific way too).

This module is fairly new to the MOP, and quite possibly will be expanded and further generalized as the need arises.

METHODS

new ($metaclass, \%options)

Given a $metaclass and a set of %options this module will prepare an immutable version of the $metaclass, which can then be applied to the $metaclass using the make_metaclass_immutable method.

options

Returns the options HASH set in new.

metaclass

Returns the metaclass set in new.

immutable_metaclass

Returns the immutable metaclass created within new.

create_immutable_metaclass

This will create the immutable version of the $metaclass, but will not actually change the original metaclass.

create_methods_for_immutable_metaclass

This will create all the methods for the immutable metaclass based on the %options passed into new.

make_metaclass_immutable

This will actually change the $metaclass into the immutable version.

AUTHORS

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2006, 2007 by Infinity Interactive, Inc.

http://www.iinteractive.com

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