Permalink
Browse files

Get rid of Module#forward_message

  • Loading branch information...
byroot committed Feb 1, 2012
1 parent 0282627 commit 1b777ef1847ce1c3d6fc3b1ff33c63a2a34bb23c
Showing with 19 additions and 24 deletions.
  1. +0 −10 lib/zip/stdrubyext.rb
  2. +19 −14 lib/zip/zipfilesystem.rb
View
@@ -62,16 +62,6 @@ def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
end
end
class Module #:nodoc:all
def forward_message(forwarder, *messagesToForward)
methodDefs = messagesToForward.map do |msg|
"def #{msg}; #{forwarder}(:#{msg}); end"
end
module_eval(methodDefs.join("\n"))
end
end
# Copyright (C) 2002, 2003 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.
View
@@ -70,29 +70,34 @@ class ZipFsFile
# protected :dir
class ZipFsStat
class << self
def delegate_to_fs_file(*methods)
methods.each do |method|
self.class_eval <<-end_eval, __FILE__, __LINE__ + 1
def #{method} # def file?
@zipFsFile.#{method}(@entryName) # @zipFsFile.file?(@entryName)
end # end
end_eval
end
end
end
def initialize(zipFsFile, entryName)
@zipFsFile = zipFsFile
@entryName = entryName
end
def forward_invoke(msg)
@zipFsFile.send(msg, @entryName)
end
def kind_of?(t)
super || t == ::File::Stat
end
forward_message :forward_invoke, :file?, :directory?, :pipe?, :chardev?
forward_message :forward_invoke, :symlink?, :socket?, :blockdev?
forward_message :forward_invoke, :readable?, :readable_real?
forward_message :forward_invoke, :writable?, :writable_real?
forward_message :forward_invoke, :executable?, :executable_real?
forward_message :forward_invoke, :sticky?, :owned?, :grpowned?
forward_message :forward_invoke, :setuid?, :setgid?
forward_message :forward_invoke, :zero?
forward_message :forward_invoke, :size, :size?
forward_message :forward_invoke, :mtime, :atime, :ctime
delegate_to_fs_file :file?, :directory?, :pipe?, :chardev?, :symlink?,
:socket?, :blockdev?, :readable?, :readable_real?, :writable?, :ctime,
:writable_real?, :executable?, :executable_real?, :sticky?, :owned?,
:grpowned?, :setuid?, :setgid?, :zero?, :size, :size?, :mtime, :atime
def blocks; nil; end

0 comments on commit 1b777ef

Please sign in to comment.