<commit_before>#    Backbone.offline allows your Backbone.js app to work offline
#    https://github.com/Ask11/backbone.offline
#
#    (c) 2012 - <NAME>
#    May be freely distributed according to MIT license.

do (global = window, _, Backbone) ->
  global.Offline =
    VERSION: '0.4.1.alfa'

    # This is a method for CRUD operations with localStorage.
    # Delegates to 'Offline.Storage' and works as ‘Backbone.sync’ alternative
    localSync: (method, model, options, store) ->
      resp = switch(method)
        when 'read'
          if _.isUndefined(model.id) then store.findAll(options) else store.find(model, options)
        when 'create' then store.create(model, options)
        when 'update' then store.update(model, options)
        when 'delete' then store.destroy(model, options)

      if resp then options.success() else options.error?('Record not found')

    # Overrides default 'Backbone.sync'. It checks 'storage' property of the model or collection
    # and then delegates to 'Offline.localSync' when property exists else calls the default 'Backbone.sync' with received params.
    sync: (method, model, options) ->
      store = model.storage || model.collection?.storage
      if store and store?.support
        Offline.localSync(method, model, options, store)<commit_msg>Fixed response at backbone.offline<commit_after>#    Backbone.offline allows your Backbone.js app to work offline
#    https://github.com/Ask11/backbone.offline
#
#    (c) 2012 - <NAME>
#    May be freely distributed according to MIT license.

do (global = window, _, Backbone) ->
  global.Offline =
    VERSION: '0.4.1.alfa'

    # This is a method for CRUD operations with localStorage.
    # Delegates to 'Offline.Storage' and works as ‘Backbone.sync’ alternative
    localSync: (method, model, options, store) ->
      resp = switch(method)
        when 'read'
          if _.isUndefined(model.id) then store.findAll(options) else store.find(model, options)
        when 'create' then store.create(model, options)
        when 'update' then store.update(model, options)
        when 'delete' then store.destroy(model, options)

      if resp
        options.success(resp.attributes ? resp)
      else
        options.error?('Record not found')

    # Overrides default 'Backbone.sync'. It checks 'storage' property of the model or collection
    # and then delegates to 'Offline.localSync' when property exists else calls the default 'Backbone.sync' with received params.
    sync: (method, model, options) ->
      store = model.storage || model.collection?.storage
      if store and store?.support
        Offline.localSync(method, model, options, store)
{'fraction_non_alphanumeric': 0.10255447032306536, 'fraction_numerical': 0.0067618332081141996, 'mean_word_length': 3.193700787401575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6980682', 'n_tokens_mistral': 771, 'n_tokens_neox': 746, 'n_words': 256}