Mercurial > pub > Impl
comparison lib/IMPL/Web/View/ObjectFactory.pm @ 407:c6e90e02dd17 ref20150831
renamed Lib->lib
author | cin |
---|---|
date | Fri, 04 Sep 2015 19:40:23 +0300 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
406:f23fcb19d3c1 | 407:c6e90e02dd17 |
---|---|
1 package IMPL::Web::View::ObjectFactory; | |
2 use strict; | |
3 | |
4 our $AUTOLOAD; | |
5 | |
6 use IMPL::declare { | |
7 require => { | |
8 Exception => 'IMPL::Exception', | |
9 OpException => '-IMPL::InvalidOperationException' | |
10 }, | |
11 base =>[ | |
12 'IMPL::Object::Factory' => '@_' | |
13 ] | |
14 }; | |
15 | |
16 use IMPL::Resources::Strings { | |
17 MsgNoMethod => 'Method "%method%" isn\'t found in "%target%"' | |
18 }; | |
19 | |
20 sub AUTOLOAD { | |
21 my $this = shift; | |
22 my ($method) = ($AUTOLOAD =~ m/(\w+)$/); | |
23 | |
24 return if $method eq 'DESTROY'; | |
25 my $target = $this->factory; | |
26 if ( $target->can($method) ) { | |
27 return $target->$method(@_); | |
28 } else { | |
29 die OpException->new( MsgNoMethod( method => $method, target => $target ) ); | |
30 } | |
31 } | |
32 | |
33 1; |