class Raterr::StoreContainer
Attributes
identifier[R]
store[R]
store_type[R]
Public Class Methods
new(store:, identifier:)
click to toggle source
# File lib/raterr/store_container.rb, line 6 def initialize(store:, identifier:) @store = store @identifier = identifier end
Public Instance Methods
resolve(method, attrs = nil)
click to toggle source
# File lib/raterr/store_container.rb, line 11 def resolve(method, attrs = nil) store_type = store.class.to_s.downcase.to_sym resolvers[method][store_type].call(attrs) end
resolvers()
click to toggle source
# File lib/raterr/store_container.rb, line 16 def resolvers { get: { hash: -> (attributes) { store.fetch(identifier) { { 'attempts' => 1, 'start_time' => Time.now } } }, redis: -> (attributes) { JSON.parse(store.get(identifier) || { 'attempts' => 1, 'start_time' => Time.now }.to_json) } }, set: { hash: -> (attributes) { store[identifier] = attributes }, redis: -> (attributes) { store.set(identifier, attributes.to_json) } }, delete: { hash: -> (identifier) { store.delete(identifier) }, redis: -> (identifier) { store.del(identifier) } } } end