class DelegateDecorator
blog.jayfields.com/2008/02/ruby-replace-methodmissing-with-dynamic.html
Public Class Methods
new(subject, options = {})
click to toggle source
# File lib/sugar-high/delegate.rb, line 44 def initialize(subject, options = {}) options[:only] ||= [] options[:except] ||= [] options[:only].map!(&:to_s) options[:except].map!(&:to_s) meths = subject.public_methods(false) meths = meths & options[:only] unless options[:only].empty? meths.each do |meth| (class << self; self; end).class_eval do unless options[:except].include? meth.to_s define_method meth do |*args| subject.send meth, *args end end end end end