Class: Hanami::Assets::Cache Private

Inherits:
Object
  • Object
show all
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.

Since:

  • 0.1.0

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Constructor Details

#initializeHanami::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

Since:

  • 0.1.0



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

Parameters:

  • file (String, Pathname)

    the file path

Returns:

  • (TrueClass, FalseClass)

    the result of the check

Since:

  • 0.3.0



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

Parameters:

  • file (String, Pathname)

    the file path

Returns:

  • (TrueClass, FalseClass)

    the result of the check

Since:

  • 0.1.0



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