Mercurial > pub > Impl
comparison Lib/IMPL/Config/Activator.pm @ 93:0667064553ef
fixed _is_class in activator
rewritten IMPL::Config::Resolve
new features in the Abstract class
author | wizard |
---|---|
date | Wed, 28 Apr 2010 17:50:55 +0400 |
parents | 3d1f584aea60 |
children | 76515373dac0 |
comparison
equal
deleted
inserted
replaced
92:5f676b61fb8b | 93:0667064553ef |
---|---|
19 | 19 |
20 } | 20 } |
21 | 21 |
22 sub _is_class { | 22 sub _is_class { |
23 no strict 'refs'; | 23 no strict 'refs'; |
24 scalar keys %{"$_[0]::"} ? 1 : 0; | 24 UNIVERSAL::can($_[0],'new') ? 1 : 0; |
25 } | 25 } |
26 | 26 |
27 sub activate { | 27 sub activate { |
28 my $this = shift; | 28 my $this = shift; |
29 | 29 |
42 } | 42 } |
43 | 43 |
44 push @args, map UNIVERSAL::isa($_,'IMPL::Config::Activator') ? $_->activate : $_, @_ if @_; | 44 push @args, map UNIVERSAL::isa($_,'IMPL::Config::Activator') ? $_->activate : $_, @_ if @_; |
45 | 45 |
46 my $factory = $this->factory; | 46 my $factory = $this->factory; |
47 eval "require $factory; 1;" unless ref $factory or _is_class($factory); | 47 eval "require $factory; 1;" unless (ref $factory or _is_class($factory)); |
48 | 48 |
49 return $this->object($factory->new(@args)); | 49 return $this->object($factory->new(@args)); |
50 } else { | 50 } else { |
51 return $this->object; | 51 return $this->object; |
52 } | 52 } |