overleaf/services/web/public/coffee/models/User.coffee

22 lines
399 B
CoffeeScript
Raw Normal View History

2014-02-12 05:23:40 -05:00
define [
"libs/backbone"
], () ->
User = Backbone.Model.extend {}, {
findOrBuild : (id, attributes) ->
model = @find id
if !model?
model = @build id
model.set model.parse attributes
return model
build: (id) ->
model = new this(id : id)
@loadedModel ||= {}
@loadedModel[id] = model
return model
find: (id) ->
@loadedModel ||= {}
return @loadedModel[id]
}