Class: Hanami::Assets::Cache::File 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.

File cache entry

Since:

  • 0.3.0

Instance Method Summary collapse

Constructor Details

#initialize(file, mtime: nil, dependencies: nil) ⇒ File

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.

Returns a new instance of File.

Since:

  • 0.3.0



21
22
23
24
25
26
# File 'lib/hanami/assets/cache.rb', line 21

def initialize(file, mtime: nil, dependencies: nil)
  @file  = file.is_a?(String) ? Pathname.new(file) : file
  @mtime = mtime || @file.mtime.utc.to_i

  @dependencies = (dependencies || []).map { |d| self.class.new(d) }
end

Instance Method Details

#modified?(other) ⇒ Boolean

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.

Returns:

  • (Boolean)

Since:

  • 0.3.0



30
31
32
33
34
35
36
37
38
39
# File 'lib/hanami/assets/cache.rb', line 30

def modified?(other)
  file = other.is_a?(self.class) ? other : self.class.new(other)

  if dependencies?
    modified_dependencies?(file) ||
      mtime <= file.mtime
  else
    mtime < file.mtime
  end
end