Class: Terminalwire::Cache::File::Store
- Inherits:
-
Object
- Object
- Terminalwire::Cache::File::Store
- Includes:
- Enumerable
- Defined in:
- lib/terminalwire/cache.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #each ⇒ Object
- #entry(key) ⇒ Object (also: #[])
- #evict ⇒ Object
-
#initialize(path:) ⇒ Store
constructor
A new instance of Store.
Constructor Details
#initialize(path:) ⇒ Store
Returns a new instance of Store.
16 17 18 19 |
# File 'lib/terminalwire/cache.rb', line 16 def initialize(path:) @path = Pathname.new(path). FileUtils.mkdir_p(@path) unless @path.directory? end |
Instance Method Details
#destroy ⇒ Object
30 31 32 |
# File 'lib/terminalwire/cache.rb', line 30 def destroy each(&:destroy) end |
#each ⇒ Object
34 35 36 37 38 |
# File 'lib/terminalwire/cache.rb', line 34 def each @path.each_child do |path| yield Entry.new(path:) end end |
#entry(key) ⇒ Object Also known as: []
21 22 23 |
# File 'lib/terminalwire/cache.rb', line 21 def entry(key) Entry.new(path: @path.join(Entry.key_path(key))) end |
#evict ⇒ Object
26 27 28 |
# File 'lib/terminalwire/cache.rb', line 26 def evict each(&:evict) end |