Class: OsCtld::Assets::Symlink

Inherits:
BaseFile show all
Defined in:
lib/osctld/assets/symlink.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #opts, #path

Instance Method Summary collapse

Methods inherited from BaseFile

#exist?, #initialize, #mode

Methods inherited from Base

#add_error, #initialize, #prefetch_zfs, register, #run_validation, #state, #type, #valid?, #validate?, #validate_block

Constructor Details

This class inherits a constructor from OsCtld::Assets::BaseFile

Instance Method Details

#statObject (protected)



19
20
21
# File 'lib/osctld/assets/symlink.rb', line 19

def stat
  @stat ||= File.lstat(path)
end

#validate(run) ⇒ Object (protected)



9
10
11
12
13
14
15
16
17
# File 'lib/osctld/assets/symlink.rb', line 9

def validate(run)
  begin
    add_error('not a symlink') if exist? && !opts[:optional] && !stat.symlink?
  rescue Errno::ENOENT
    add_error('does not exist')
  end

  super
end