digitalhelpersleague/asterism

View on GitHub
app/assets/javascripts/rism/resources/extension.js.coffee

Summary

Maintainability
Test Coverage
@rism.factory "Extension", ["$resource", "data", ($resource, data) ->

  Extension = $resource("/extensions/:id.json", { id: '@id' },
    update: { method: 'PUT' }
  )

  cache = do ->
    if data.extensions?
      _.map(data.extensions, (extension) -> new Extension(extension))

  Extension.all = ->
    cache || Extension.query()

  Extension
]