Sha256: 6b31ad8a30f07e72b70dea10bfa92a93f06a48c89202caccc92405c945a753f6

Contents?: true

Size: 910 Bytes

Versions: 71

Compression:

Stored size: 910 Bytes

Contents

if RUBY_PLATFORM == 'opal'
  module Volt
    module LocalStorage
      def self.[](key)
        `
          var val = localStorage.getItem(key);
          return val === null ? nil : val;
        `
      end

      def self.[]=(key, value)
        `localStorage.setItem(key, value)`
      end

      def self.clear
        `localStorage.clear()`
        self
      end

      def self.delete(key)
        `
          var val = localStorage.getItem(key);
          localStorage.removeItem(key);
          return val === null ? nil : val;
        `
      end
    end
  end
else
  module Volt
    module LocalStorage
      @@store = {}

      def self.[](key)
        @@store[key]
      end

      def self.[]=(key, value)
        @@store[key] = value
      end

      def self.clear
        @@store = {}

        self
      end

      def self.delete(key)
        @@store.delete(key)
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 lib/volt/utils/local_storage.rb
volt-0.9.7.pre7 lib/volt/utils/local_storage.rb
volt-0.9.7.pre6 lib/volt/utils/local_storage.rb
volt-0.9.7.pre5 lib/volt/utils/local_storage.rb
volt-0.9.7.pre3 lib/volt/utils/local_storage.rb
volt-0.9.7.pre2 lib/volt/utils/local_storage.rb
volt-0.9.6 lib/volt/utils/local_storage.rb
volt-0.9.6.pre3 lib/volt/utils/local_storage.rb
volt-0.9.6.pre2 lib/volt/utils/local_storage.rb
volt-0.9.6.pre1 lib/volt/utils/local_storage.rb
volt-0.9.5 lib/volt/utils/local_storage.rb
volt-0.9.5.pre12 lib/volt/utils/local_storage.rb
volt-0.9.5.pre11 lib/volt/utils/local_storage.rb
volt-0.9.5.pre9 lib/volt/utils/local_storage.rb
volt-0.9.5.pre8 lib/volt/utils/local_storage.rb
volt-0.9.5.pre7 lib/volt/utils/local_storage.rb
volt-0.9.5.pre6 lib/volt/utils/local_storage.rb
volt-0.9.5.pre5 lib/volt/utils/local_storage.rb
volt-0.9.5.pre4 lib/volt/utils/local_storage.rb
volt-0.9.5.pre3 lib/volt/utils/local_storage.rb