Sha256: c13b24db707e34b77a8b747759ac106d1159bc194f3475015c15dfd1f011ae6d

Contents?: true

Size: 913 Bytes

Versions: 22

Compression:

Stored size: 913 Bytes

Contents

require './queryable'

handlers =
  store_after_saved: ->
    # TODO remove global model usage
    {storage} = model[@resource.toString()]

    # TODO check persistable configuration before attaching handlers
    # and remove the @_id presence check
    storage.store @_id, @ if @_id


persistable =
  record:
    after_initialize: ->
      if @_id
        # TODO remove global model usage
        {storage} = model[@resource.toString()]
        storage.store @_id, @
      else
        # TODO check persistable configuration before attaching handlers
        @after 'saved', handlers.store_after_saved

# Extend indemma
# TODO use stampit to extend record and model
model  = window.model     # TODO better way to get parent
record = window.record     # TODO better way to get parent

model.persistable = true

model.mix (modelable) ->
  modelable.record.after_initialize.push persistable.record.after_initialize

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ende-0.5.1 components/indefinido/indemma/master/src/lib/record/persistable.coffee
ende-0.4.20 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.19 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.18 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.17 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.16 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.15 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.14 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.13 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.12 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.11 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.10 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.9 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.8 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.7 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.6 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.5 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.4 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.3 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.2 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee