File | /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Relationship/ProxyMethods.pm | Statements Executed | 22 | Total Time | 0.00037 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine | |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | DBIx::Class::Relationship::ProxyMethods:: | BEGIN |
0 | 0 | 0 | 0 | 0 | DBIx::Class::Relationship::ProxyMethods:: | __ANON__[:32] |
0 | 0 | 0 | 0 | 0 | DBIx::Class::Relationship::ProxyMethods:: | proxy_to_related |
0 | 0 | 0 | 0 | 0 | DBIx::Class::Relationship::ProxyMethods:: | register_relationship |
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package # hide from PAUSE | |||
2 | DBIx::Class::Relationship::ProxyMethods; | |||
3 | ||||
4 | 3 | 3.3e-5 | 1.1e-5 | use strict; # spent 11µs making 1 call to strict::import |
5 | 3 | 3.1e-5 | 1.0e-5 | use warnings; # spent 21µs making 1 call to warnings::import |
6 | ||||
7 | 3 | 0.00011 | 3.6e-5 | use base qw/DBIx::Class/; # spent 97µs making 1 call to base::import |
8 | ||||
9 | sub register_relationship { | |||
10 | 6 | 2.7e-5 | 4.5e-6 | my ($class, $rel, $info) = @_; |
11 | if (my $proxy_list = $info->{attrs}{proxy}) { | |||
12 | $class->proxy_to_related($rel, | |||
13 | (ref $proxy_list ? @$proxy_list : $proxy_list)); | |||
14 | } | |||
15 | $class->next::method($rel, $info); # spent 44µs making 2 calls to next::method, avg 22µs/call | |||
16 | } | |||
17 | ||||
18 | sub proxy_to_related { | |||
19 | my ($class, $rel, @proxy) = @_; | |||
20 | 3 | 2.9e-5 | 9.7e-6 | no strict 'refs'; # spent 19µs making 1 call to strict::unimport |
21 | 3 | 0.00014 | 4.7e-5 | no warnings 'redefine'; # spent 29µs making 1 call to warnings::unimport |
22 | foreach my $proxy (@proxy) { | |||
23 | *{"${class}::${proxy}"} = | |||
24 | sub { | |||
25 | my $self = shift; | |||
26 | my $val = $self->$rel; | |||
27 | if (@_ && !defined $val) { | |||
28 | $val = $self->create_related($rel, { $proxy => $_[0] }); | |||
29 | @_ = (); | |||
30 | } | |||
31 | return ($val ? $val->$proxy(@_) : undef); | |||
32 | } | |||
33 | } | |||
34 | } | |||
35 | ||||
36 | 1 | 2.0e-6 | 2.0e-6 | 1; |