openfoodfoundation/openfoodnetwork

View on GitHub
app/assets/javascripts/darkswarm/services/shops.js.coffee

Summary

Maintainability
Test Coverage
angular.module("Darkswarm").factory 'Shops', ($injector) ->
  new class Shops
    all: []
    byID: {}

    constructor: ->
      if $injector.has('shops')
        @load($injector.get('shops'))

    load: (shops) ->
      for shop in shops
        @all.push shop
        @byID[shop.id] = shop