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.25 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.24 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.23 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.5.1 components/indefinido/indemma/master/src/lib/record/storable.coffee
ende-0.4.22 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.21 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.5.0 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.20 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.19 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.18 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.17 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.16 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.15 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.14 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.13 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.12 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.11 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.10 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.9 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.4.8 vendor/components/indefinido-indemma/src/lib/record/storable.coffee