annotate lib/IMPL/Web/View/ObjectFactory.pm @ 415:3d24b10dd0d5 ref20150831

working on IMPL::Config::Container
author cin
date Tue, 20 Oct 2015 07:32:55 +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::Web::View::ObjectFactory;
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 our $AUTOLOAD;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 require => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 Exception => 'IMPL::Exception',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 OpException => '-IMPL::InvalidOperationException'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 base =>[
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 'IMPL::Object::Factory' => '@_'
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
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 use IMPL::Resources::Strings {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 MsgNoMethod => 'Method "%method%" isn\'t found in "%target%"'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 sub AUTOLOAD {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 return if $method eq 'DESTROY';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25 my $target = $this->factory;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 if ( $target->can($method) ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 return $target->$method(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 die OpException->new( MsgNoMethod( method => $method, target => $target ) );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 1;