class Hanami::Assets::Cache::File

File cache entry

@since 0.3.0 @api private

Attributes

dependencies[R]

@since 0.3.0 @api private

mtime[R]

@since 0.3.0 @api private

Public Class Methods

new(file, mtime: nil, dependencies: nil) click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/cache.rb, line 22
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

Public Instance Methods

modified?(other) click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/cache.rb, line 31
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

Protected Instance Methods

dependencies?() click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/cache.rb, line 60
def dependencies?
  dependencies.any?
end
modified_dependencies?(other) click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/cache.rb, line 54
def modified_dependencies?(other)
  dependencies.all? { |dep| dep.mtime > other.mtime }
end