annotate lib/IMPL/Object/AutoDispose.pm @ 417:3ed0c58e9da3 ref20150831

working on di container, tests
author cin
date Mon, 02 Nov 2015 01:56:53 +0300
parents c6e90e02dd17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Object::AutoDispose;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4 sub new {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 my $self = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 if (ref $self) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 return ${$self}->new(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 my $obj = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 return bless \$obj, $self;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 sub isa {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 ${shift(@_)}->isa(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 sub can {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 ${shift(@_)}->can(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 sub DESTROY {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 ${shift(@_)}->Dispose();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 sub AUTOLOAD {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28 our $AUTOLOAD;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 no strict 'refs';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 goto &{*{$AUTOLOAD} = sub {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34 ${shift(@_)}->$method(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35 }};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 1;