commit 7030e82eca6c3f78cb5a745c8fd0aa6f8d3b3008
parent 2f78a8362adcce901d6afdd52fc21c6bbc9dbf19
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date: Tue, 18 Jan 2011 19:09:32 -0800
Merge branch 'master' into next
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -607,6 +607,14 @@ module Singleton
## special-case every call to a Singleton object
return nil if @instance.nil?
+ # Speed up further calls by defining a shortcut around method_missing
+ if meth.to_s[-1,1] == '='
+ # Argh! Inconsistency! Setters do not work like all the other methods.
+ class_eval "def self.#{meth}(a); @instance.send :#{meth}, a; end"
+ else
+ class_eval "def self.#{meth}(*a, &b); @instance.send :#{meth}, *a, &b; end"
+ end
+
@instance.send meth, *a, &b
end
def init *args