Sha256: 40d9d326e2b9fa0dee411b50ca3c217d907d1fd3162ec09d99ffc230d188317c

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

class Joosy.Resources.Array extends Array

  Joosy.Module.merge @, Joosy.Module

  @include Joosy.Modules.Events
  @include Joosy.Modules.Filters

  @registerPlainFilters 'beforeLoad'

  @build: ->
    new @ arguments...

  constructor: ->
    @__fillData arguments, false

  load: ->
    @__fillData arguments

  get: (index) ->
    @[index]

  set: (index, value) ->
    @[index] = value
    @trigger 'changed'
    value

  push: ->
    result = super
    @trigger 'changed'
    result

  pop: ->
    result = super
    @trigger 'changed'
    result

  shift: ->
    result = super
    @trigger 'changed'
    result

  unshift: ->
    result = super
    @trigger 'changed'
    result

  splice: ->
    result = super
    @trigger 'changed'
    result

  __fillData: (data, notify=true) ->
    data = @slice.call(data, 0)

    @splice 0, @length if @length > 0
    @push entry for entry in @__applyBeforeLoads(data)

    @trigger 'changed' if notify

    null

# AMD wrapper
if define?.amd?
  define 'joosy/resources/array', -> Joosy.Resources.Array

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joosy-1.2.0.beta.4 source/joosy/resources/array.coffee
joosy-1.2.0.beta.3 source/joosy/resources/array.coffee
joosy-1.2.0.beta.2 source/joosy/resources/array.coffee