Sha256: a43b0c5d68d106cc079304a6e858b1c99c056034550254b2f51ea614d95b52bc

Contents?: true

Size: 519 Bytes

Versions: 2

Compression:

Stored size: 519 Bytes

Contents

module DOM
  class LocalStorage
    def initialize(storage)
      @storage = storage
    end

    def []=(key, value)
      %x{
        #@storage.setItem(key, value);
        return value;
      }
    end

    def [](key)
      %x{
        var value = #@storage.getItem(key);
        return value == null ? nil : value;
      }
    end

    def delete(key)
      `#@storage.removeItem(key)`
    end

    def clear
      `#@storage.clear()`
    end
  end
end

LocalStorage = DOM::LocalStorage.new(`window.localStorage`)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-jquery-0.3.0.beta1 opal/opal-jquery/local_storage.rb
opal-jquery-0.2.0 opal/opal-jquery/local_storage.rb