MooseX::NaturalKey::Meta::Class - MooseX::NaturalKey::Meta::Class documentation


MooseX-NaturalKey documentation  | view source Contained in the MooseX-NaturalKey distribution.

Index


NAME

Top

MooseX::NaturalKey::Meta::Class

SYNOPSIS

Top

    # in your class which mimics Moose.pm;
    sub import {
        my $caller = caller;
        Moose::init_meta
	    ($caller,
	     'Moose::Object',
	     'MooseX::NaturalKey::Meta::Class');

        Moose->import({ into => $caller });
    }

    # if you wanted special behaviour you could define:
    package My::NaturalKey::Meta::Class;
    extends 'MooseX::NaturalKey::Meta::Class

    # override where the instance cache comes from
    override cache => sub {
        my $self = shift;
        return \%cache;
    };

    # alternative method
    my %cache;
    __PACKAGE__->meta->cache(\%cache);

    # override how the primary keys are transformed into a
    # cache hash slot
    override make_cache_key => sub {
        my $self = shift;
        my $names_arrayref = shift;
        my $values_arrayref = shift;

        # example
        join "\0", @$values_arrayref;
    };




DESCRIPTION

Top

This metaclass implements 'Natural Key' Moose classes. So, when you create a new MooseX::NaturalKey, it creates one of these objects. During object construction, creating the actual instance is deferred to the created object.

After the object is constructed as normal, it checks using the primary keys list it knows about, what the values of those slots are in the constructed object.

SEE ALSO

Top

MooseX::NaturalKey, Moose::Meta::Class.

AUTHOR AND LICENSE

Top

Copyright 2008, Sam Vilain, <samv@cpan.org>. All Rights Reserved.

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


MooseX-NaturalKey documentation  | view source Contained in the MooseX-NaturalKey distribution.