concept ServiceUtils in category rails
appears as: ServiceUtils, ServiceUtils

This is an excerpt from Manning's book Flexible Rails: Flex 3 on Rails 2.
Listing 8.21. app\flex\com\pomodo\business\ProjectDelegate.as
package com.pomodo.business { import mx.rpc.IResponder; import com.pomodo.util.ServiceUtils; public class ProjectDelegate { private var _responder:IResponder; public function ProjectDelegate(responder:IResponder) { _responder = responder; } public function listProjects():void { ServiceUtils.send("/projects.xml", _responder); } public function createProject(project:XML):void { ServiceUtils.send("/projects.xml", _responder, project, true); } public function updateProject( projectID:int, keys: Array, values: Array):void { var params:Object = new Object(); for (var i:int = 0; i < keys.length; i++) { params['project[' + keys[i] +']'] = values[i]; } params['_method'] = "PUT"; ServiceUtils.send( "/projects/" + projectID + ".xml", _responder, params); } public function destroyProject(projectID:int):void { ServiceUtils.send( "/projects/" + projectID + ".xml", _responder, {_method: "DELETE"}); } } }It sets
the _responder
(which is the command that invoked it), and uses ServiceUtils to list
, create
, update
, and destroy
projects. Note that the _responder is passed to all these calls, so that ServiceUtils can add it as a responder to the service call. This _responder is whatever Command is using the Delegate. Specifically, it’s the following:
Next, we’ll add two nonstandard classes that will simplify (without oversimplifying) how we use Cairngorm: CairngormUtils and ServiceUtils.
the _responder
(which is the command that invoked it), and uses ServiceUtils to list
, create
, update
, and destroy
projects. Note