Class: Browser::SessionStorage

Inherits:
Storage show all
Defined in:
opal/browser/storage.rb

Overview

A SessionStorage allows you to store data across page reloads, as long as the session is active.

Instance Attribute Summary

Attributes inherited from Storage

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Storage

#[]=, #autosave!, #autosave?, #clear, #commit, #delete, #each, #initialize, json_create, #method_missing, #no_autosave!, #replace, #to_h, #to_json

Constructor Details

This class inherits a constructor from Browser::Storage

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Browser::Storage

Class Method Details

.supported?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'opal/browser/storage.rb', line 219

def self.supported?
  Browser.supports? 'Storage.session'
end

Instance Method Details

#reloadObject



223
224
225
# File 'opal/browser/storage.rb', line 223

def reload
  replace `#@window.sessionStorage[#@name] || '{}'`
end

#saveObject



227
228
229
# File 'opal/browser/storage.rb', line 227

def save
  `#@window.sessionStorage[#@name] = #{JSON.dump(self)}`
end