Sha256: 7301816f3baa820064fdd4e2dbfc6fb02ef2e5eba67adb7ae567e91ba98c60ca

Contents?: true

Size: 602 Bytes

Versions: 3

Compression:

Stored size: 602 Bytes

Contents

# Persistence module built on top of NSUserDefaults
module BubbleWrap
  module Persistence
    module_function

    def app_key
      @app_key ||= BubbleWrap::App.identifier
    end

    def []=(key, value)
      defaults = NSUserDefaults.standardUserDefaults
      defaults.setObject(value, forKey: storage_key(key.to_s))
      defaults.synchronize
    end

    def [](key)
      defaults = NSUserDefaults.standardUserDefaults
      defaults.objectForKey storage_key(key.to_s)
    end

    def storage_key(key)
      app_key + '_' + key.to_s
    end
  end

end
::Persistence = BubbleWrap::Persistence

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bubble-wrap-0.4.0 motion/core/persistence.rb
bubble-wrap-0.3.1 lib/bubble-wrap/persistence.rb
bubble-wrap-0.3.0 lib/bubble-wrap/persistence.rb