public/lib/emberjs/ember.js
function(params, transition) {
        var match, name, sawParams, value;

        var queryParams = get(this, '_qp.map');

        for (var prop in params) {
          if (prop === 'queryParams' || (queryParams && prop in queryParams)) {
            continue;
          }

          if (match = prop.match(/^(.*)_id$/)) {
            name = match[1];
            value = params[prop];
          }
          sawParams = true;
        }

        if (!name && sawParams) { return copy(params); }
        else if (!name) {
          if (transition.resolveIndex < 1) { return; }

          var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;

          return parentModel;
        }

        return this.findModel(name, value);
      }
function(params, transition) {
        var match, name, sawParams, value;

        var queryParams = get(this, '_qp.map');

        for (var prop in params) {
          if (prop === 'queryParams' || (queryParams && prop in queryParams)) {
            continue;
          }

          if (match = prop.match(/^(.*)_id$/)) {
            name = match[1];
            value = params[prop];
          }
          sawParams = true;
        }

        if (!name && sawParams) { return copy(params); }
        else if (!name) {
          if (transition.resolveIndex < 1) { return; }

          var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;

          return parentModel;
        }

        return this.findModel(name, value);
      }
function ( params , transition ) { var match , name , sawParams , value ; var queryParams = get ( this , '_qp.map' ) ; for ( var prop in params ) { if ( prop === 'queryParams' || ( queryParams && prop in queryParams ) ) { continue ; } if ( match = prop . match ( / ^(.*)_id$ / ) ) { name = match [ 1 ] ; value = params [ prop ] ; } sawParams = true ; } if ( ! name && sawParams ) { return copy ( params ) ; } else if ( ! name ) { if ( transition . resolveIndex < 1 ) { return ; } var parentModel = transition . state . handlerInfos [ transition . resolveIndex - 1 ] . context ; return parentModel ; } return this . findModel ( name , value ) ; }
A hook you can implement to convert the URL into the model for
this route.

```js
App.Router.map(function() {
this.resource('post', {path: '/posts/:post_id'});
});
```

The model for the `post` route is `store.find('post', params.post_id)`.

By default, if your route has a dynamic segment ending in `_id`:

The model class is determined from the segment (`post_id`'s
class is `App.Post`)
The find method is called on the model class with the value of
the dynamic segment.

Note that for routes with dynamic segments, this hook is not always
executed. If the route is entered through a transition (e.g. when
using the `link-to` Handlebars helper or the `transitionTo` method
of routes), and a model context is already provided this hook
is not called.

A model context does not include a primitive string or number,
which does cause the model hook to be called.

Routes without dynamic segments will always execute the model hook.

```js
no dynamic segment, model hook always called
this.transitionTo('posts');

model passed in, so model hook not called
thePost = store.find('post', 1);
this.transitionTo('post', thePost);

integer passed in, model hook is called
this.transitionTo('post', 1);
```


This hook follows the asynchronous/promise semantics
described in the documentation for `beforeModel`. In particular,
if a promise returned from `model` fails, the error will be
handled by the `error` hook on `Ember.Route`.

Example

```js
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});
```

@method model
@param {Object} params the parameters extracted from the URL
@param {Transition} transition
@param {Object} queryParams the query params for this route
@return {Object|Promise} the model for this route. If
a promise is returned, the transition will pause until
the promise resolves, and the resolved value of the promise
will be used as the model for this route.
A hook you can implement to convert the URL into the model for this route .