lib/sugar-high/delegate.rb in sugar-high-0.7.1 vs lib/sugar-high/delegate.rb in sugar-high-0.7.2

- old
+ new

@@ -36,5 +36,19 @@ } end end end end + +# http://blog.jayfields.com/2008/02/ruby-replace-methodmissing-with-dynamic.html +class DelegateDecorator + def initialize(subject) + subject.public_methods(false).each do |meth| + (class << self; self; end).class_eval do + define_method meth do |*args| + subject.send meth, *args + end + end + end + end +end +