| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package KiokuDB::Class; | ||
| 4 | |||
| 5 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 3 | ▶ | use Moose (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 3 | ▶ | use Moose::Exporter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 3 | ▶ | use Moose::Util::MetaRole; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 3 | ▶ | use KiokuDB::Meta::Instance; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 3 | ▶ | use KiokuDB::Meta::Attribute::Lazy; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 3 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | 3 | Moose::Exporter->setup_import_methods( also => 'Moose' ); | |
| 18 | |||
| 19 | sub init_meta { | ||
| 20 | 3 | ▶ | my ( $class, %args ) = @_; |
|
Subroutine
init_meta: called CC=1 SCAR=0.1
Pod
undocumented
| |||
| 21 | |||
| 22 | 3 | my $for_class = $args{for_class}; | |
| 23 | |||
| 24 | 3 | Moose->init_meta(%args); | |
| 25 | |||
| 26 | 3 | Moose::Util::MetaRole::apply_metaclass_roles( | |
| 27 | for_class => $for_class, | ||
| 28 | instance_metaclass_roles => [qw(KiokuDB::Meta::Instance)], | ||
| 29 | ); | ||
| 30 | |||
| 31 | 0 | return Class::MOP::get_metaclass_by_name($for_class); | |
| 32 | } | ||
| 33 | |||
| 34 | 3 | __PACKAGE__ | |
| 35 | |||
| 36 | __END__ | ||
| 37 | |||
| 38 | =pod | ||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | KiokuDB::Class - L<KiokuDB> specific metaclass | ||
| 43 | |||
| 44 | =head1 SYNOPSIS | ||
| 45 | |||
| 46 | package Foo; | ||
| 47 | use KiokuDB::Class; # instead of Moose | ||
| 48 | |||
| 49 | has bar => ( | ||
| 50 | traits => [qw(KiokuDB::Lazy)], | ||
| 51 | ... | ||
| 52 | ); | ||
| 53 | |||
| 54 | =head1 DESCRIPTION | ||
| 55 | |||
| 56 | This L<Moose> wrapper provides some metaclass extensions in order to more | ||
| 57 | tightly integrate your class with L<KiokuDB>. | ||
| 58 | |||
| 59 | Currently only L<KiokuDB::Meta::Attribute::Lazy> is set up (by extending | ||
| 60 | L<Moose::Meta::Instance> with a custom role to support it), but in the future | ||
| 61 | indexing, identity, and various optimizations will be supported by this. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||