Sha256: 5b432213b222a3c6c3f7b60a60dfc1ced52a404e1005e33e90de6181c6fab3c8

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

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:
    # TODO better caching check after resource initialization
    # TODO think how to retrieve already stored resources
    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

8 entries across 8 versions & 1 rubygems

Version Path
ende-0.5.22 components/indefinido/indemma/master/src/lib/record/persistable.coffee
ende-0.5.21 components/indefinido/indemma/master/src/lib/record/persistable.coffee
ende-0.4.25 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.24 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.23 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.22 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.4.21 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee
ende-0.5.0 vendor/components/indefinido-indemma/src/lib/record/persistable.coffee