mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 00:43:41 -05:00
21 lines
399 B
CoffeeScript
21 lines
399 B
CoffeeScript
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]
|
|
}
|