Class: Lich::Common::SetupFiles::FileInfo
- Inherits:
-
Object
- Object
- Lich::Common::SetupFiles::FileInfo
- Defined in:
- documented/common/setup_files.rb
Overview
Holds parsed YAML file content with metadata for cache validation.
Provides deep-cloned data access to prevent external mutation of cached settings, with automatic retry on transient Ruby iteration errors.
Constant Summary collapse
- DEEP_COPY_ATTEMPTS =
Attempts at a deep clone before a transient iteration error propagates.
3
Instance Attribute Summary collapse
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#data ⇒ Object
Deep clone of data to prevent scripts from mutating cached settings.
-
#initialize(path:, name:, data:, mtime:, digest: nil) ⇒ void
constructor
Creates a FileInfo instance with parsed YAML content and metadata.
-
#inspect ⇒ String
Returns a string representation of this FileInfo for debugging.
-
#peek(property) ⇒ Object
Efficient deep clone of a single property.
-
#to_s ⇒ String
Returns the full path to the cached file.
Constructor Details
#initialize(path:, name:, data:, mtime:, digest: nil) ⇒ void
Creates a FileInfo instance with parsed YAML content and metadata.
64 65 66 67 68 69 70 |
# File 'documented/common/setup_files.rb', line 64 def initialize(path:, name:, data:, mtime:, digest: nil) @path = path @name = name @data = data @mtime = mtime @digest = digest end |
Instance Attribute Details
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
54 55 56 |
# File 'documented/common/setup_files.rb', line 54 def digest @digest end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
54 55 56 |
# File 'documented/common/setup_files.rb', line 54 def mtime @mtime end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
54 55 56 |
# File 'documented/common/setup_files.rb', line 54 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
54 55 56 |
# File 'documented/common/setup_files.rb', line 54 def path @path end |
Instance Method Details
#data ⇒ Object
Deep clone of data to prevent scripts from mutating cached settings.
73 74 75 |
# File 'documented/common/setup_files.rb', line 73 def data deep_copy(@data) end |
#inspect ⇒ String
Returns a string representation of this FileInfo for debugging.
92 93 94 |
# File 'documented/common/setup_files.rb', line 92 def inspect "#<SetupFiles::FileInfo @name=#{@name}, @path=#{@path}, @mtime=#{@mtime}, @digest=#{@digest}>" end |
#peek(property) ⇒ Object
Efficient deep clone of a single property.
78 79 80 |
# File 'documented/common/setup_files.rb', line 78 def peek(property) deep_copy(@data[property.to_sym]) end |
#to_s ⇒ String
Returns the full path to the cached file.
85 86 87 |
# File 'documented/common/setup_files.rb', line 85 def to_s File.join(@path, @name) end |