Sha256: bc74ef4c8c1d8fd5fa19f2dbc8b9743b259db8741a67ea40354370bb53316e2f

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

class Joosy.Resources.Array extends Array

  Joosy.Module.include.call @, Joosy.Modules.Events
  Joosy.Module.include.call @, Joosy.Modules.Filters

  @registerPlainFilters 'beforeLoad'

  constructor: ->
    @__fillData arguments, false

  get: (index) ->
    @[index]

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

  load: ->
    @__fillData arguments

  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 = if data[0] instanceof Array
      data[0]
    else
      @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

1 entries across 1 versions & 1 rubygems

Version Path
joosy-1.2.0.alpha.71 source/joosy/resources/array.coffee