Class: Undo::Storage::RailsCache
- Inherits:
-
Adapter
- Object
- Adapter
- Undo::Storage::RailsCache
- Defined in:
- lib/undo/storage/rails_cache.rb
Instance Method Summary collapse
- #delete(uuid, options = {}) ⇒ Object
- #fetch(uuid, options = {}) ⇒ Object
-
#initialize(cache = nil, options = {}) ⇒ RailsCache
constructor
A new instance of RailsCache.
- #store(uuid, object, options = {}) ⇒ Object
Constructor Details
#initialize(cache = nil, options = {}) ⇒ RailsCache
6 7 8 9 10 11 |
# File 'lib/undo/storage/rails_cache.rb', line 6 def initialize(cache = nil, = {}) @cache = cache @cache ||= Rails.cache if defined? Rails super end |
Instance Method Details
#delete(uuid, options = {}) ⇒ Object
24 25 26 |
# File 'lib/undo/storage/rails_cache.rb', line 24 def delete(uuid, = {}) cache.delete uuid, () end |
#fetch(uuid, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/undo/storage/rails_cache.rb', line 19 def fetch(uuid, = {}) raise KeyError, "key #{uuid} not found" unless cache.exist? uuid unpack cache.read uuid, () end |
#store(uuid, object, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/undo/storage/rails_cache.rb', line 13 def store(uuid, object, = {}) cache.write uuid, pack(object), () end |