Class: MemFs::Fake::Symlink

Inherits:
Entry
  • Object
show all
Includes:
MemFs::FilesystemAccess
Defined in:
lib/memfs/fake/symlink.rb

Constant Summary

Constants inherited from Entry

Entry::GEXEC, Entry::GREAD, Entry::GWRITE, Entry::OEXEC, Entry::OREAD, Entry::OWRITE, Entry::RSTICK, Entry::SETGID, Entry::SETUID, Entry::UEXEC, Entry::UREAD, Entry::USTICK, Entry::UWRITE

Instance Attribute Summary collapse

Attributes inherited from Entry

#atime, #block_device, #character_device, #ctime, #gid, #mode, #mtime, #name, #parent, #uid

Instance Method Summary collapse

Methods inherited from Entry

#blksize, #delete, #dev, #ino, #path, #paths, #touch

Constructor Details

#initialize(path, target) ⇒ Symlink

Returns a new instance of Symlink.



28
29
30
31
# File 'lib/memfs/fake/symlink.rb', line 28

def initialize(path, target)
  super(path)
  @target = target
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/memfs/fake/symlink.rb', line 33

def method_missing(meth, *args, &block)
  if dereferenced.respond_to?(meth)
    dereferenced.public_send(meth, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



8
9
10
# File 'lib/memfs/fake/symlink.rb', line 8

def target
  @target
end

Instance Method Details

#dereferencedObject



10
11
12
# File 'lib/memfs/fake/symlink.rb', line 10

def dereferenced
  @dereferenced ||= fs.find!(target).dereferenced
end

#dereferenced_nameObject



14
15
16
# File 'lib/memfs/fake/symlink.rb', line 14

def dereferenced_name
  real_target.dereferenced_name
end

#dereferenced_pathObject



18
19
20
# File 'lib/memfs/fake/symlink.rb', line 18

def dereferenced_path
  dereferenced.dereferenced_path
end

#find(path) ⇒ Object



22
23
24
25
26
# File 'lib/memfs/fake/symlink.rb', line 22

def find(path)
  dereferenced.find(path)
rescue Errno::ENOENT
  nil
end

#respond_to_missing?(meth, include_private) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/memfs/fake/symlink.rb', line 41

def respond_to_missing?(meth, include_private)
  dereferenced.respond_to?(meth, include_private) || super
end

#typeObject



45
46
47
# File 'lib/memfs/fake/symlink.rb', line 45

def type
  'link'
end