Sha256: 34358958cce5d2e443198675b4464e0cc594cd9d7c1d74f85c17f94f93332f1e

Contents?: true

Size: 970 Bytes

Versions: 26

Compression:

Stored size: 970 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

26 entries across 26 versions & 1 rubygems

Version Path
ende-0.3.13 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.12 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.11 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.10 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.9 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.8 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.7 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.6 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.5 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.4 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.3 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.2 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.1 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.3.0 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.2.21 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.2.20 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.2.19 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.2.18 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.2.17 vendor/components/indefinido-indemma/src/lib/record/storable.coffee
ende-0.2.16 vendor/components/indefinido-indemma/src/lib/record/storable.coffee