cartodb/services/data-repository/backend/memory.rb

28 lines
486 B
Ruby
Raw Normal View History

2020-06-15 10:58:47 +08:00
require 'set'
require 'json'
module DataRepository
module Backend
class Memory < Hash
def store(key, data, options={})
data = data.to_a if data.is_a?(Set) # OMG FIXME
super(key, JSON.parse(data.to_json))
end
def fetch(key, options={})
super key
end
def exists?(key)
self.has_key?(key)
end
# Not supported, so just call data
def transaction(&block)
block.call
end
end
end
end