public function respondTo($responses)
    {
        $format = $this->request()->format();
        
        foreach ($responses as $fmt => $action) {
            if (is_int($fmt)) {
                $fmt = $action;
                $action = null;
            }
            
            if ($fmt !== $format)
                continue;
            
            if ($action) {
                if (!$action instanceof Closure) {
                    throw new Exception\InvalidArgumentException(sprinft('Only closure can be passed to respondTo, %s passed', gettype($action)));
                }
                $action();
            } else {
                $action = true;
            }
            
            $this->_respond_action = $action;
            return;
        }
        
        /**
         * The request format is not acceptable.
         * Set to render nothing with 406 status.
         */
        Rails::log()->message("406 Not Acceptable");
        $this->render(array('nothing' => true), array('status' => 406));
    }
public function respondTo($responses)
    {
        $format = $this->request()->format();
        
        foreach ($responses as $fmt => $action) {
            if (is_int($fmt)) {
                $fmt = $action;
                $action = null;
            }
            
            if ($fmt !== $format)
                continue;
            
            if ($action) {
                if (!$action instanceof Closure) {
                    throw new Exception\InvalidArgumentException(sprinft('Only closure can be passed to respondTo, %s passed', gettype($action)));
                }
                $action();
            } else {
                $action = true;
            }
            
            $this->_respond_action = $action;
            return;
        }
        
        /**
         * The request format is not acceptable.
         * Set to render nothing with 406 status.
         */
        Rails::log()->message("406 Not Acceptable");
        $this->render(array('nothing' => true), array('status' => 406));
    }
public function respondTo ( $ responses ) { $ format = $ this -> request ( ) -> format ( ) ; foreach ( $ responses as $ fmt => $ action ) { if ( is_int ( $ fmt ) ) { $ fmt = $ action ; $ action = null ; } if ( $ fmt !== $ format ) continue ; if ( $ action ) { if ( ! $ action instanceof Closure ) { throw new Exception \ InvalidArgumentException ( sprinft ( 'Only closure can be passed to respondTo, %s passed' , gettype ( $ action ) ) ) ; } $ action ( ) ; } else { $ action = true ; } $ this -> _respond_action = $ action ; return ; } /**
         * The request format is not acceptable.
         * Set to render nothing with 406 status.
         */ Rails :: log ( ) -> message ( "406 Not Acceptable" ) ; $ this -> render ( array ( 'nothing' => true ) , array ( 'status' => 406 ) ) ; }
Respond to format

Sets to which formats the action will respond.
It accepts a list of methods that will be called if the
request matches the format.

Example:
$this->respondTo(array(
'html',
'xml' => array(
'_some_method' => array($param_1, $param_2),
'_render'      => array(array('xml' => $obj), array('status' => 403))
)
));

Note: The way this function receives its parameters is because we can't use Closures,
due to the protected visibility of the methods such as _render().

In the case above, it's stated that the action is able to respond to html and xml.
In the case of an html request, no further action is needed to respond; therefore,
we just list the 'html' format there.
In the case of an xml request, the controller will call _some_method($param_1, $param_2)
then it will call the _render() method, giving it the variable with which it will respond
(an ActiveRecord_Base object, an array, etc), and setting the status to 403.
Any request with a format not specified here will be responded with a 406 HTTP status code.

By default all requests respond to xml, json and html. If the action receives a json
request for example, but no data is set to respond with, the dispatcher will look for
the .$format.php file in the views (in this case, .json.php). If the file is missing,
which actually is expected to happen, a Dispatcher_TemplateMissing exception will be
thrown.

@see respond_with()
Respond to format