Class: Cache
- Inherits:
-
Object
- Object
- Cache
- Includes:
- Autostruct::Wrap
- Defined in:
- lib/middleman/caching_proxy/cache.rb
Instance Method Summary collapse
- #add(item:, source:) ⇒ Object
- #full_path(item:) ⇒ Object
- #has?(item) ⇒ Boolean
-
#initialize(path:, key:) ⇒ Cache
constructor
A new instance of Cache.
- #save ⇒ Object
Constructor Details
#initialize(path:, key:) ⇒ Cache
Returns a new instance of Cache.
7 8 9 |
# File 'lib/middleman/caching_proxy/cache.rb', line 7 def initialize(path:, key:) @manifest = nil end |
Instance Method Details
#add(item:, source:) ⇒ Object
18 19 20 21 22 |
# File 'lib/middleman/caching_proxy/cache.rb', line 18 def add(item:, source:) manifest.add item cached_path = full_path(item: item) copy_in source, cached_path end |
#full_path(item:) ⇒ Object
24 25 26 |
# File 'lib/middleman/caching_proxy/cache.rb', line 24 def full_path(item:) ::File.join(path, "items", item.path) end |
#has?(item) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/middleman/caching_proxy/cache.rb', line 12 def has?(item) cached_path = full_path(item: item) return false if !::File.exist?(cached_path) manifest.has?(item) end |
#save ⇒ Object
28 29 30 |
# File 'lib/middleman/caching_proxy/cache.rb', line 28 def save manifest.save end |