Sha256: c57a82411071c2bb09266c6f5796f02c0dba6811e11450d42f55c5bfe93b98c9
Contents?: true
Size: 948 Bytes
Versions: 1
Compression:
Stored size: 948 Bytes
Contents
# # It allows you dynamically (magically) switch between UniversalEntry/Dir/File # module Vfs class EntryProxy < BasicObject attr_reader :_target # WRAP = [:[], :entry, :dir, :file].to_set 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 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 # return WRAP.include?(m) ? EntryProxy.new(result) : result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vfs-0.3.13 | lib/vfs/entry_proxy.rb |