407
|
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; |