Class: Lotus::Assets::Cache Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/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 expecially useful in development mode, where we want to compile only the assets that were changed from last browser refresh.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

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



16
17
18
19
# File 'lib/lotus/assets/cache.rb', line 16

def initialize
  @data  = Hash.new{|h,k| h[k] = 0 }
  @mutex = Mutex.new
end

Instance Method Details

#fresh?(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 is fresh or changed from last check.

Parameters:

  • file (String, Pathname)

    the file path

Returns:

  • (TrueClass, FalseClass)

    the result of the check

Since:

  • 0.1.0



29
30
31
32
33
# File 'lib/lotus/assets/cache.rb', line 29

def fresh?(file)
  @mutex.synchronize do
    @data[file.to_s] < mtime(file)
  end
end

#store(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.

Store the given file reference

Parameters:

  • file (String, Pathname)

    the file path

Returns:

  • (TrueClass, FalseClass)

    the result of the check

Since:

  • 0.1.0



43
44
45
46
47
# File 'lib/lotus/assets/cache.rb', line 43

def store(file)
  @mutex.synchronize do
    @data[file.to_s] = mtime(file)
  end
end