File Coverage

blib/lib/VoiceXML/Client/Item/Assign.pm
Criterion Covered Total %
statement 27 29 93.1
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 37 43 86.0


line stmt bran cond sub pod time code
1              
2             package VoiceXML::Client::Item::Assign;
3              
4              
5 3     3   17 use strict;
  3         6  
  3         103  
6              
7              
8 3     3   15 use base qw (VoiceXML::Client::Item);
  3         129  
  3         204  
9 3     3   16 use VoiceXML::Client::Util;
  3         6  
  3         68  
10              
11 3         858 use vars qw{
12             $VERSION
13 3     3   15 };
  3         5  
14              
15             $VERSION = $VoiceXML::Client::Item::VERSION;
16              
17              
18              
19             =head1 COPYRIGHT AND LICENSE
20              
21            
22             Copyright (C) 2007,2008 by Pat Deegan.
23             All rights reserved
24             http://voicexml.psychogenic.com
25              
26             This library is released under the terms of the GNU GPL version 3, making it available only for
27             free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
28             Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
29             acquire a distinct license for their application. This approach encourages the use of free software
30             while allowing for proprietary solutions that support further development.
31              
32              
33             This file is part of VoiceXML::Client.
34              
35            
36            
37             VoiceXML::Client is free software: you can redistribute it and/or modify
38             it under the terms of the GNU General Public License as published by
39             the Free Software Foundation, either version 3 of the License, or
40             (at your option) any later version.
41              
42             VoiceXML::Client is distributed in the hope that it will be useful,
43             but WITHOUT ANY WARRANTY; without even the implied warranty of
44             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45             GNU General Public License for more details.
46              
47             You should have received a copy of the GNU General Public License
48             along with VoiceXML::Client. If not, see .
49              
50              
51             =cut
52              
53              
54              
55              
56             sub init {
57 10     10 1 15 my $self = shift;
58            
59 10         30 my $name = $self->{'XMLElement'}->attribute('name');
60 10         138 my $val = $self->{'XMLElement'}->attribute('expr') ;
61            
62 10 50       120 $val = '' unless (defined $val);
63              
64 10 50       23 unless (defined $name)
65             {
66 0         0 VoiceXML::Client::Util::log_msg("Assign:init() no name set for element (with expr $val)");
67 0         0 return undef;
68             }
69            
70 10         33 my $vxmlDoc = $self->getParentVXMLDocument()->registerVariable($name);
71            
72            
73 10         24 $self->{'name'} = $name;
74 10         28 $self->{'expr'} = $val;
75            
76 10         25 return 1;
77            
78            
79             }
80              
81             sub execute {
82 3     3 0 7 my $self = shift;
83 3         6 my $handle = shift;
84 3         5 my $optParams = shift;
85            
86 3 50       10 VoiceXML::Client::Util::log_msg("ASSIGN SETTING $self->{'name'} to '$self->{'expr'}'") if ($VoiceXML::Client::Debug > 1);
87            
88 3         18 VoiceXML::Client::Item::Util->assignVariable($self, $self->{'name'}, $self->{'expr'});
89              
90            
91            
92 3         22 return $self->executeChildren($handle, $optParams);
93             }
94            
95              
96              
97              
98             1;