Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/anemone/storage/base.rb
Views: 11779
require 'anemone/storage/exceptions'12module Anemone3module Storage4class Base56def initialize(adapter)7@adap = adapter89# verify adapter conforms to this class's methods10methods.each do |method|11if !@adap.respond_to?(method.to_sym)12raise "Storage adapter must support method #{method}"13end14end15end1617def [](key)18@adap[key]19rescue20puts key21raise RetrievalError, $!22end2324def []=(key, value)25@adap[key] = value26rescue27raise InsertionError, $!28end2930def delete(key)31@adap.delete(key)32rescue33raise DeletionError, $!34end3536def each37@adap.each { |k, v| yield k, v }38rescue39raise GenericError, $!40end4142def merge!(hash)43@adap.merge!(hash)44rescue45raise GenericError, $!46end4748def close49@adap.close50rescue51raise CloseError, $!52end5354def size55@adap.size56rescue57raise GenericError, $!58end5960def keys61@adap.keys62rescue63raise GenericError, $!64end6566def has_key?(key)67@adap.has_key?(key)68rescue69raise GenericError, $!70end7172end73end74end757677