diff Lib/IMPL/Web/View/TTControl.pm @ 353:feeb3bc4a818

corrected error handling while loading templates corrected variables lookup in controls updated handles to use the new view features
author cin
date Fri, 11 Oct 2013 15:49:04 +0400
parents 675cd1829255
children 97131d500f16
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTControl.pm	Thu Oct 10 19:51:19 2013 +0400
+++ b/Lib/IMPL/Web/View/TTControl.pm	Fri Oct 11 15:49:04 2013 +0400
@@ -14,7 +14,6 @@
 	props => [
 		context => PROP_RO,
 		template => PROP_RO,
-		_stash => PROP_RO,
 		id => {
 	   		get => sub { shift->_stash->get('id') },
 	   		set => sub { shift->_stash->set('id',shift) }
@@ -39,8 +38,10 @@
     	or die ArgException->new(context => 'A context is required');
     $this->template($template)
     	or die ArgException->new(template => 'A template is required');
-    	
-    $this->_stash($context->stash);
+}
+
+sub _stash {
+	$_[0]->context->stash;
 }
 
 sub Render {
@@ -52,17 +53,18 @@
 sub AUTOLOAD {
 	my ($prop) = ($AUTOLOAD =~ m/(\w+)$/);
 	
-	die Exception->new("Control doesn't have method '$prop'") unless $prop=~/$AUTOLOAD_REGEX/;
+	die Exception->new("Method not found: $AUTOLOAD") unless $prop=~/$AUTOLOAD_REGEX/ and $_[0];
 	
 	no strict 'refs';
 	
 	my $method = sub {
-		if (@_ == 1) {
-			return shift->_stash->get($prop);
-		} elsif (@_ == 2) {
-			return shift->_stash->set($prop,shift);
+		my $that = shift;
+		if (@_ == 0) {
+			return $that->_stash->get($prop);
+		} elsif (@_ == 1) {
+			return $that->_stash->set($prop,shift);
 		} else {
-			return shift->_stash->get([$prop,[@_]]);
+			return $that->_stash->get([$prop,[@_]]);
 		}
 	};