File Coverage

blib/lib/MooseX/Meta/Method/Transactional/Application/ToInstance.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package MooseX::Meta::Method::Transactional::Application::ToInstance;
2 5     5   16786 use Moose::Role;
  5         8  
  5         27  
3              
4             after apply => sub {
5             my ($self, $role, $instance, $args) = @_;
6              
7             $instance->meta->add_role($role);
8              
9             my $original_body = $instance->body;
10             my $new_body = sub {
11 3     3   749 my ($self) = @_;
12 3         95 $instance->schema->($self)->txn_do($original_body, @_);
13             };
14              
15             # HACK! XXX!
16              
17             # 1 - body is ro in Method, need to force the change,,,
18             $instance->{body} = $new_body;
19              
20             # 2 - need to reinstall the CODE ref in the glob
21 5     5   16979 no warnings 'redefine';
  5         9  
  5         175  
22 5     5   19 no strict 'refs';
  5         6  
  5         271  
23             *{$instance->package_name.'::'.$instance->name} = $new_body;
24             };
25              
26             1;