Sha256: 5552e7d0fd6b59d5f7b767f0bea27ac50b90abad236b2d3b82d4266e0a5c0e31
Contents?: true
Size: 1012 Bytes
Versions: 2
Compression:
Stored size: 1012 Bytes
Contents
# It allows dynamically (magically) switching between UniversalEntry/Dir/File. module Vfs class EntryProxy < BasicObject attr_reader :_target def initialize entry raise 'something wrong happening here!' if entry.respond_to?(:proxy?) and entry.proxy? self._target = entry end def proxy? true end protected :==, :equal?, :!, :!= protected attr_writer :_target def respond_to? m super or ::Vfs::UniversalEntry.method_defined?(m) or ::Vfs::Dir.method_defined?(m) or ::Vfs::File.method_defined?(m) end def method_missing m, *a, &b unless _target.respond_to? m if ::Vfs::UniversalEntry.method_defined? m self.target = _target.entry elsif ::Vfs::Dir.method_defined? m self._target = _target.dir elsif ::Vfs::File.method_defined? m self._target = _target.file end end _target.send m, *a, &b end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vfs-0.5.1 | lib/vfs/entry_proxy.rb |
vfs-0.5.0 | lib/vfs/entry_proxy.rb |