diff Lib/IMPL/Web/Application/Action.pm @ 55:609b59c9f03c

Web application rewrote prop_list implementation to support IMPL::Object::List
author wizard
date Wed, 03 Mar 2010 17:40:18 +0300
parents 15d720913562
children 117b6956d5a5
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/Action.pm	Tue Mar 02 20:15:57 2010 +0300
+++ b/Lib/IMPL/Web/Application/Action.pm	Wed Mar 03 17:40:18 2010 +0300
@@ -1,4 +1,5 @@
 package IMPL::Web::Application::Action;
+use strict;
 
 use base qw(IMPL::Object);
 
@@ -8,8 +9,39 @@
 	public property application => prop_get | owner_set;
 	public property request => prop_get | owner_set;
 	public property response => prop_get | owner_set;
-	public property code => prop_get | owner_set;
-	public property chainHandlers => prop_get | owner_set | prop_list;
+	
+	private property _entryPoint => prop_all;
+}
+
+sub Invoke {
+	my ($this) = @_;
+	
+	if ($this->_entryPoint) {
+		$this->_entryPoint->();
+	} else {
+		die new IMPL::InvalidOperationException("At least one handler is required");
+	}
+}
+
+sub ChainHandler {
+	my ($this,$handler) = @_;
+	
+	my $delegate;
+
+	my $delegateNext = $this->_entryPoint();
+	
+	if (ref $handler eq 'CODE') {
+		$delegate = sub {
+			$handler->($this,$delegateNext);			
+		};
+	} elsif (UNIVERSAL::isa($handler,'IMPL::Web::Application::QueryHandler')) {
+		$delegate = sub {
+			$handler->Invoke($this,$delegateNext);
+		}
+	} else {
+		die new IMPL::InvalidArgumentException("An invalid handler supplied");
+	}
+	
 }
 
 1;