merge performance branch into main
[scpubgit/stemmatology.git] / lib / Text / Tradition / TypeMap / Entry.pm
1 package Text::Tradition::TypeMap::Entry;
2 use Moose;
3
4 no warnings 'recursion';
5
6 use namespace::clean -except => 'meta';
7
8 with qw(KiokuDB::TypeMap::Entry::Std);
9
10 use YAML::XS ();
11
12 sub compile_collapse_body {
13     my ( $self, $class ) = @_;
14
15     return sub {
16         my ( $self, %args ) = @_;
17
18         my $object = $args{object};
19
20         return $self->make_entry(
21             %args,
22             data => YAML::XS::Dump($object)
23         );
24     };
25 }
26
27 sub compile_expand {
28     my ( $self, $class ) = @_;
29
30     return sub {
31         my ( $self, $entry ) = @_;
32         $self->inflate_data( YAML::XS::Load($entry->data), \( my $obj ), $entry );
33
34         bless $obj, $class;
35     };
36 }
37
38 sub compile_refresh { return sub { die "TODO" } }
39
40 __PACKAGE__->meta->make_immutable;
41
42 1;