cartodb-4.42/services/data-repository/backend/memory.rb
2024-04-06 05:25:13 +00:00

28 lines
486 B
Ruby

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