diff Lib/IMPL/Web/Application/Action.pm @ 323:b56b1ec33b59

minor changes to support JSON in transformation from a query to an object
author sergey
date Thu, 23 May 2013 18:40:26 +0400
parents cca158327c47
children b1e7b55b4a38
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/Action.pm	Tue May 21 10:04:11 2013 +0400
+++ b/Lib/IMPL/Web/Application/Action.pm	Thu May 23 18:40:26 2013 +0400
@@ -14,7 +14,16 @@
         'IMPL::Object::Autofill' => '@_'
     ],
     props => [
-        application => PROP_RO,
+        application => {
+        	get => sub {
+        		carp "Action->application is deprecated use Resource->application instead.";
+        		shift->_app();
+        	},
+        	set => sub {
+        		shift->_app(@_);
+        	}
+        },
+        _app => PROP_RW,
         query => PROP_RO,
         context => PROP_RW,
         _jsonData => PROP_RW,
@@ -43,6 +52,10 @@
 	shift->query->https ? 1 : 0;
 }
 
+sub isJson {
+	return shift->contentType =~ m{^application/json} ? 1 : 0;
+}
+
 sub param {
     my ($this,$name,$rx) = @_;
     
@@ -87,7 +100,7 @@
 sub jsonData {
     my ($this) = @_;
     
-    if ($this->contentType =~ m{^application/json} ) {
+    if ($this->isJson ) {
         my $data = $this->_jsonData;
         unless($data) {
             $data = JSON->new()->decode($this->rawData('decode encoding'));