ObjectProxy handles properties , I need it to handle method calls as well. Here’s some sample code. Ideally javascript would let me intercept unhandle method calls on an object. It doesn’t so I’d like to do the following. In AuthObjectProxy.init, iterate over all of the instance methods of ‘search_model’ and then create theses methods for the AuthObjectProxy instance so I can forward them on the ‘content’ object. How do I get the instance methods of search_model?
App.MyAuthRoute = Ember.Route.extend
model: (params) ->
App.AuthObjectProxy.create
object_id: params.post_id
search_model: App.Post`
App.AuthObjectProxy = Ember.ObjectProxy.extend
init: ->
@_super
if App.Auth.get('signedIn')
@set 'content', @get('search_model').find(@get('object_id'))
else
@set 'content', null
App.Auth.on 'signInComplete', =>
@set 'content', @get('search_model').find(@get('object_id'))
App.Auth.on 'signOutComplete', =>
@set 'content', null
#TODO dynamically intercept method calls and forward onto object
save: ->
@get('content').save(arguments)