| 1 | package WebDAO::Lexer::object; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | WebDAO::Lexer::object - Process object tag | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | WebDAO::Lexer::object - Process object tag | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | our $VERSION = '0.01'; | ||
| 16 | use base 'WebDAO::Lexer::base'; | ||
| 17 | use strict; | ||
| 18 | use warnings; | ||
| 19 | use Data::Dumper; | ||
| 20 | |||
| 21 | sub value { | ||
| 22 | my $self = shift; | ||
| 23 | my $eng = shift; | ||
| 24 | my @args = (); | ||
| 25 | |||
| 26 | #skip not any | ||
| 27 | foreach my $c ( $self->childs ) { | ||
| 28 | unless ( UNIVERSAL::isa( $c, 'WebDAO::Lexer::base' ) ) { | ||
| 29 | print "Bad element at " . ref($c); | ||
| 30 | |||
| 31 | # next; | ||
| 32 | } | ||
| 33 | |||
| 34 | #get values | ||
| 35 | push @args, $c->value($eng); | ||
| 36 | } | ||
| 37 | |||
| 38 | #warn "Result: " . Dumper([@args]). Dumper($self->attr); | ||
| 39 | if ($eng) { | ||
| 40 | my $error; | ||
| 41 | my $attr = $self->attr; | ||
| 42 | |||
| 43 | #check if alias | ||
| 44 | unless ( $eng->_pack4name( $attr->{class} ) ) { | ||
| 45 | |||
| 46 | #try class as perl modulename | ||
| 47 | $error = $eng->register_class( $attr->{class} ); | ||
| 48 | |||
| 49 | } | ||
| 50 | if ($error) { | ||
| 51 | |||
| 52 | # _log1 $self | ||
| 53 | warn "use module $attr->{class} id: $attr->{id} fail. $error"; | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | else { | ||
| 57 | my $object = $eng->_create_( $attr->{id}, $attr->{class}, @args ); | ||
| 58 | |||
| 59 | # _log1 $self | ||
| 60 | warn "create_obj fail for class: " | ||
| 61 | . $attr->{class} | ||
| 62 | . " ,id: " | ||
| 63 | . $attr->{id} | ||
| 64 | unless $object; | ||
| 65 | |||
| 66 | return $object; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | 1; | ||
| 71 | __DATA__ | ||
| 72 | |||
| 73 | =head1 SEE ALSO | ||
| 74 | |||
| 75 | http://sourceforge.net/projects/webdao | ||
| 76 | |||
| 77 | =head1 AUTHOR | ||
| 78 | |||
| 79 | Zahatski Aliaksandr, E<lt>zag@cpan.orgE<gt> | ||
| 80 | |||
| 81 | =head1 COPYRIGHT AND LICENSE | ||
| 82 | |||
| 83 | Copyright 2002-2011 by Zahatski Aliaksandr | ||
| 84 | |||
| 85 | This library is free software; you can redistribute it and/or modify | ||
| 86 | it under the same terms as Perl itself. | ||
| 87 | |||
| 88 | =cut | ||
| 89 |