Skip to content

Instantly share code, notes, and snippets.

View ghempton's full-sized avatar

Gordon L. Hempton ghempton

View GitHub Profile
@ghempton
ghempton / gist:11389065
Created April 29, 2014 02:00
Transactional Route
`import Route from 'outreach/core/route'`
# Route which manages a transaction on it's content.
# E.g. when the route is exited, the transaction will
# be rolled back
class TransactionalRoute extends Route
resolveSession: (parentSession) ->
@session = parentSession.newSession()
@ghempton
ghempton / gist:11389007
Created April 29, 2014 01:55
Epf Route
`import CurrentUserMixin from 'outreach/core/current_user_mixin'`
`import Model from 'outreach/core/model'`
class Route extends Em.Route with CurrentUserMixin
+computed
title: ->
'Outreach'
enter: ->
@ghempton
ghempton / gist:9882197
Created March 30, 2014 23:58
EPF Adapter URL API
Adapter.map(function() {
this.resources('post', {path: '/blog-posts/:post_id'}, function() {
this.resources('comments'); // assumes has-many called 'comments' and inverse called 'post'
this.resource('owner', {type: 'user'});
});
});
@ghempton
ghempton / route.em
Created March 5, 2014 02:57
Example of using EPF child sessions at the route level
`import CurrentUserMixin from 'outreach/core/current_user_mixin'`
class Route extends Em.Route with CurrentUserMixin
beforeModel: (transition) ->
parentRoute = if transition.state.handlerInfos.length > 1
transition.state.handlerInfos[transition.state.handlerInfos.length - 2].handler
else
null
@setupSession(parentRoute)