EntityModel

 view release on metacpan or  search on metacpan

lib/EntityModel/Util.pm  view on Meta::CPAN

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
=item * goodbye - coderef to call after success/failure. This will always be called regardless
of status, and can be used to chain events similar to L<CPS>.
 
=back
 
Returns the transaction in list or scalar context, and in void
context will clean up the transaction automatically.
 
=cut
 
sub as_transaction(&;@) {
        my $code = shift;
        my %args = @_;
        my $tran = EntityModel::Transaction->new;
        $tran->run($code, %args);
        # unless we're in void context, pass the transaction back for something else
        # to take a crack at it
        return $tran if defined wantarray;
        $tran->commit;
        undef;
}

lib/Test/EntityModel.pm  view on Meta::CPAN

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
                        name => 'book_author',
                        primary => [qw(idbook idauthor)],
                        field => [
                                { name => 'book', type => 'text', },
                                { name => 'author', type => '', },
                        ],
                } ],
        },
);
 
sub with_model(&;@) {
        my $code = shift;
        my %args = @_;
        my $def = $model_data{$args{model} || 'simple'} or die 'unknown model - ' . $args{model};
 
        my $weak_model;
        {
                my $model = EntityModel->default_model;
                Scalar::Util::weaken($weak_model = $model);
                $model->add_storage(
                        # TODO extract this



( run in 0.232 second using v1.01-cache-2.11-cpan-cba739cd03b )