annotate Lib/IMPL/Web/View/ObjectFactory.pm @ 339:97628101b765

refactoring: application now holds a security object factory rather than a security object
author cin
date Wed, 19 Jun 2013 03:25:44 +0400
parents 7c517134c42f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
240
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
1 package IMPL::Web::View::ObjectFactory;
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
2 use strict;
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
3
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
4 our $AUTOLOAD;
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
5
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
6 use IMPL::declare {
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
7 require => {
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
8 Exception => 'IMPL::Exception',
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
9 OpException => '-IMPL::InvalidOperationException'
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
10 },
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
11 base =>[
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
12 'IMPL::Object::Factory' => '@_'
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
13 ]
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
14 };
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
15
245
7c517134c42f Added Unsupported media type Web exception
sergey
parents: 240
diff changeset
16 use IMPL::Resources::Strings {
7c517134c42f Added Unsupported media type Web exception
sergey
parents: 240
diff changeset
17 MsgNoMethod => 'Method "%method%" isn\'t found in "%target%"'
7c517134c42f Added Unsupported media type Web exception
sergey
parents: 240
diff changeset
18 };
7c517134c42f Added Unsupported media type Web exception
sergey
parents: 240
diff changeset
19
240
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
20 sub AUTOLOAD {
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
21 my $this = shift;
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
22 my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
23
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
24 return if $method eq 'DESTROY';
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
25 my $target = $this->factory;
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
26 if ( $target->can($method) ) {
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
27 return $target->$method(@_);
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
28 } else {
245
7c517134c42f Added Unsupported media type Web exception
sergey
parents: 240
diff changeset
29 die OpException->new( MsgNoMethod( method => $method, target => $target ) );
240
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
30 }
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
31 }
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
32
abc7c26bf615 +Added ObjectFactory for templates with static members support
sergey
parents:
diff changeset
33 1;