EntityModel
view release on metacpan or search on metacpan
lib/EntityModel/Util.pm view on Meta::CPAN
434445464748495051525354555657585960616263=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
525354555657585960616263646566676869707172
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 )