mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
22 lines
399 B
CoffeeScript
22 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]
|
||
|
}
|