| 1 | package RWDE::CCRproxy; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use base qw(RWDE::Proxy); | ||
| 6 | |||
| 7 | use vars qw($VERSION); | ||
| 8 | $VERSION = sprintf "%d", q$Revision: 507 $ =~ /(\d+)/; | ||
| 9 | |||
| 10 | =pod | ||
| 11 | |||
| 12 | =head1 RWDE::CCRproxy | ||
| 13 | |||
| 14 | Proxy object for getting the specific functionality of a particular object | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | =head2 decode({ type=> object_type, enc =>object_enc}) | ||
| 19 | |||
| 20 | To avoid require and instantiation the proxy object returns the decoded value of the passed encoded id. | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | sub decode { | ||
| 25 | my ($self,$params) = @_; | ||
| 26 | |||
| 27 | return $self->invoke({class => $$params{'type'}, function => 'decode', params => $$params{'enc'}}); | ||
| 28 | } | ||
| 29 | |||
| 30 | =head2 ccr_to_id({ type=> object_type, ccr =>object_ccr}) | ||
| 31 | |||
| 32 | To avoid require and instantiation the proxy object returns the id value from the passed ccr. | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | sub ccr_to_id { | ||
| 37 | my ($self,$params) = @_; | ||
| 38 | |||
| 39 | return $self->invoke({class => $$params{'type'}, function => 'ccr_to_id', params => $$params{'ccr'} }); | ||
| 40 | } | ||
| 41 | |||
| 42 | =head2 invoke({ class => class_name, function => function_name, params => function_params}) | ||
| 43 | |||
| 44 | override base method "invoke" from Proxy.pm | ||
| 45 | |||
| 46 | =cut | ||
| 47 | |||
| 48 | sub invoke { | ||
| 49 | my ($self,$params) = @_; | ||
| 50 | |||
| 51 | my $function = $$params{'function'} | ||
| 52 | or throw RWDE::DevelException({ info => 'Proxy::Parameter error - function not specified'}); | ||
| 53 | |||
| 54 | my $term = RWDE::AbstractFactory->instantiate({class => $$params{'class'}}); | ||
| 55 | |||
| 56 | return $term->$function($$params{'params'}); | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; |