class ExchangeRateJt::DataStore::PStoreAdaptor
Attributes
data_store[R]
Public Class Methods
new(data_store)
click to toggle source
# File lib/exchange_rate_jt/data_store/p_store_adaptor.rb, line 11 def initialize(data_store) unless data_store.is_a?(PStore) raise InvalidConnectionTypeError, 'Invalid connection type' end @data_store = data_store end
Public Instance Methods
fetch(key, value)
click to toggle source
# File lib/exchange_rate_jt/data_store/p_store_adaptor.rb, line 25 def fetch(key, value) data = data_store.transaction { data_store[key][value] } raise DataNotFoundError, 'Data not found' if data.nil? data rescue raise DataNotFoundError, 'Data not found' end
persist(key, value)
click to toggle source
# File lib/exchange_rate_jt/data_store/p_store_adaptor.rb, line 18 def persist(key, value) data_store.transaction do data_store[key] = value data_store.commit end end