Sha256: e8624c696eec2a96e3bcda9f313d86420b8b234b6f2adb9dfc5826dab500d883

Contents?: true

Size: 933 Bytes

Versions: 4

Compression:

Stored size: 933 Bytes

Contents

#= require ./collection

#
# Collection of REST Resources
#
# @include Joosy.Modules.Log
# @include Joosy.Modules.Events
#
class Joosy.Resources.RESTCollection extends Joosy.Resources.Collection
  @include Joosy.Modules.Log
  @include Joosy.Modules.Events

  #
  # Refetches the data from backend and triggers `changed`
  #
  # @param [Hash] options         See {Joosy.Resources.REST.find} for possible options
  # @param [Function] callback    Resulting callback
  # @param [Object]   callback    `(error, instance, data) -> ...`
  #
  reload: (options={}, callback=false) ->
    if Object.isFunction(options)
      callback = options
      options  = {}

    @model.__query @model.collectionPath(options, @__source), 'GET', options.params, (error, data, xhr) =>
      @load data if data?
      callback?(error, @, data, xhr)

  load: (args...) ->
    res = super(args...)
    @data.each (x) =>
      x.__source = @__source
    res

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
joosy-1.2.0.alpha.71 source/joosy/extensions/resources/rest_collection.coffee
joosy-1.2.0.alpha.70 source/joosy/extensions/resources/rest_collection.coffee
joosy-1.2.0.alpha.68 source/joosy/extensions/resources/rest_collection.coffee
joosy-1.2.0.alpha.67 source/joosy/extensions/resources/rest_collection.coffee