Sha256: b74475b79fa6a60f652148a8a32d06cb8a3ca2417309d10d5ad82f0546cc601c

Contents?: true

Size: 918 Bytes

Versions: 22

Compression:

Stored size: 918 Bytes

Contents

class SessionStore
  extend Isomorfeus::BrowserStoreApi

  class << self
    def method_missing(key, *args, &block)
      if Isomorfeus.on_browser?
        if `args.length > 0`
          key = `key.endsWith('=')` ? key.chop : key
          value = args[0]
          `Opal.global.sessionStorage.setItem(key, value)`
          notify_subscribers
          value
        else
          # check store for value
          value = `Opal.global.sessionStorage.getItem(key)`
          return value if value
        end
      end
      # otherwise return nil
      return nil
    end

    alias [] method_missing
    alias []= method_missing

    alias get method_missing
    alias set method_missing

    def delete(key)
      `Opal.global.sessionStorage.removeItem(key)`
      notify_subscribers
      nil
    end

    def clear
      `Opal.global.sessionStorage.clear()`
      notify_subscribers
      nil
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
isomorfeus-redux-4.2.0 lib/session_store.rb
isomorfeus-redux-4.1.18 lib/session_store.rb
isomorfeus-redux-4.1.17 lib/session_store.rb
isomorfeus-redux-4.1.16 lib/session_store.rb
isomorfeus-redux-4.1.15 lib/session_store.rb
isomorfeus-redux-4.1.14 lib/session_store.rb
isomorfeus-redux-4.1.13 lib/session_store.rb
isomorfeus-redux-4.1.12 lib/session_store.rb
isomorfeus-redux-4.1.11 lib/session_store.rb
isomorfeus-redux-4.1.10 lib/session_store.rb
isomorfeus-redux-4.1.9 lib/session_store.rb
isomorfeus-redux-4.1.8 lib/session_store.rb
isomorfeus-redux-4.1.7 lib/session_store.rb
isomorfeus-redux-4.1.6 lib/session_store.rb
isomorfeus-redux-4.1.5 lib/session_store.rb
isomorfeus-redux-4.1.4 lib/session_store.rb
isomorfeus-redux-4.1.3 lib/session_store.rb
isomorfeus-redux-4.1.2 lib/session_store.rb
isomorfeus-redux-4.1.1 lib/session_store.rb
isomorfeus-redux-4.1.0 lib/session_store.rb