Class: Hanami::Assets::Cache Private
- Inherits:
-
Object
- Object
- Hanami::Assets::Cache
- Defined in:
- lib/hanami/assets/cache.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Store assets references when compile mode is on.
This is especially useful in development mode, where we want to compile only the assets that were changed from last browser refresh.
Defined Under Namespace
Classes: File
Instance Method Summary collapse
-
#initialize ⇒ Hanami::Assets::Cache
constructor
private
Return a new instance.
-
#modified?(file) ⇒ TrueClass, FalseClass
private
Check if the given file was modified.
-
#store(file, dependencies = nil) ⇒ TrueClass, FalseClass
private
Store the given file reference.
Constructor Details
#initialize ⇒ Hanami::Assets::Cache
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a new instance
67 68 69 70 |
# File 'lib/hanami/assets/cache.rb', line 67 def initialize @data = Hash.new { |h, k| h[k] = File.new(k, mtime: 0) } @mutex = Mutex.new end |
Instance Method Details
#modified?(file) ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the given file was modified
80 81 82 83 84 |
# File 'lib/hanami/assets/cache.rb', line 80 def modified?(file) @mutex.synchronize do @data[file.to_s].modified?(file) end end |
#store(file, dependencies = nil) ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Store the given file reference
94 95 96 97 98 |
# File 'lib/hanami/assets/cache.rb', line 94 def store(file, dependencies = nil) @mutex.synchronize do @data[file.to_s] = File.new(file, dependencies: dependencies) end end |