Mercurial > pub > Impl
comparison Lib/IMPL/Config/Reference.pm @ 198:2ffe6f661605
Implemented IMPL::Web::Handler::RestController
fixes in IMPL::Serialization
completed IMPL::Web::Application::RestResource
added IMPL::Web::Handler::JSONView
added IMPL::Web::RestContract
author | cin |
---|---|
date | Fri, 20 Apr 2012 16:06:36 +0400 |
parents | a705e848dcc7 |
children |
comparison
equal
deleted
inserted
replaced
197:6b1dda998839 | 198:2ffe6f661605 |
---|---|
1 package IMPL::Config::Reference; | 1 package IMPL::Config::Reference; |
2 use strict; | 2 use strict; |
3 | 3 |
4 use IMPL::Exception; | 4 use IMPL::Exception; |
5 | |
6 __PACKAGE__->PassThroughArgs; | |
7 | 5 |
8 sub restore { | 6 sub restore { |
9 my ($self,$data,$surrogate) = @_; | 7 my ($self,$data,$surrogate) = @_; |
10 | 8 |
11 my @path; | 9 my @path; |
12 | 10 |
13 my ($tagTarget,$target) = splice @$data, 0, 2; | 11 my ($tagTarget,$target) = splice @$data, 0, 2; |
14 | 12 |
15 die new IMPL::Exception('A traget tag must be the first tag in the reference specification') unless $tagTarget eq 'target'; | 13 die new IMPL::Exception('A traget tag must be the first tag in the reference specification') unless $tagTarget eq 'target'; |
16 | |
17 while(my ($method,$args) = splice @$data, 0, 2 ) { | 14 while(my ($method,$args) = splice @$data, 0, 2 ) { |
18 $target = $self->_Invoke({ method => $method, args => $args}); | 15 $target = $self->_InvokeMember($target,{ method => $method, args => $args}); |
19 } | 16 } |
20 return $target; | 17 return $target; |
21 } | 18 } |
22 | 19 |
23 sub _InvokeMember { | 20 sub _InvokeMember { |
24 my ($self,$object,$member) = @_; | 21 my ($self,$object,$member) = @_; |
25 | 22 |
26 my $method = $member->{method}; | 23 my $method = $member->{method}; |
27 | 24 return |
28 local $@; | |
29 return eval { | |
30 ref $object eq 'HASH' ? | 25 ref $object eq 'HASH' ? |
31 $object->{$method} | 26 $object->{$method} |
32 : | 27 : |
33 $object->$method( | 28 $object->$method( |
34 exists $member->{args} ? | 29 exists $member->{args} ? |
35 _as_list($member->{args}) | 30 _as_list($member->{args}) |
36 : | 31 : |
37 () | 32 () |
38 ) | 33 ) |
39 }; | 34 ; |
40 } | 35 } |
41 | 36 |
42 sub _as_list { | 37 sub _as_list { |
43 ref $_[0] ? | 38 ref $_[0] ? |
44 (ref $_[0] eq 'HASH' ? | 39 (ref $_[0] eq 'HASH' ? |