Sha256: 208c5dfb55f455e8d40808e79a1431b1235e4bb86809ae855db12636d729fb59

Contents?: true

Size: 972 Bytes

Versions: 28

Compression:

Stored size: 972 Bytes

Contents

extend  = require 'assimilate'
merge   = extend.withStrategy 'deep'
stampit = require '../../vendor/stampit'

storable = stampit
  store: (keypath, value, options) ->
    collection = @database
    keypath = keypath.toString().split '.'
    key     = keypath.pop()

    for entry in keypath
      collection[entry] ||= {}
      collection = collection[entry]

    if arguments.length == 1
      @reads++
      collection[key]
    else
      @writes++

      # TODO use object.defineProperty
      value.sustained ||= true
      collection[key] = value

  values: ->
    Object.values @database
  ,
    type: 'object'
    writes: 0
    reads: 0
  , ->
    @database ||= {}
    @


# 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.storable = true
module.exports = storable
#model.mix (modelable) ->
#  merge modelable, storable.model


Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ende-0.4.7 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.6 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.5 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.4 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.3 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.2 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.1 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.0 vendor/components/indefinido-indemma/src/lib/record/storable.coffee