batmanjs/batman — pull request #891 by TheJeff (2013-11-12 05:38:18+00:00)
Title: Make belongsTo always return a BelongsToProxy

Sometimes you want to call a method on an object once it is loaded. Say I have the following object model:

```
class App.Organization extends Batman.Model
@hasMany 'events'

class App.Event extends Batman.Model
@belongsTo 'organization'

onLoaded: (key, callback) ->
if @get("#{key}.loaded") || @get(key) instanceof Batman.Model
callback()
else
@observeOnce "#{key}.loaded", => callback()
```
And say you execute this code
```
App.Event.find 1, (err, event) =>
event.onLoaded 'organization', =>
console.log event.get('organization') # BelongsToProxy
console.log event.get('organization.target') # Organization
console.log event.get('organization.loaded') # false
event.onLoaded 'organization', =>
event.get('organization') # Organization
event.get('organization.target') # undefined
event.get('organization.loaded') # undefined
```
This inconsistent API really makes it hard to execute code on the loaded object. Also, a loading indicator based on the loaded accessor won't work.

This PR will change the belongsTo relationships always return a BelongsToProxy.

@nickjs @pushrax thoughts?