Class: DelegateDecorator
Overview
Instance Method Summary collapse
-
#initialize(subject, options = {}) ⇒ DelegateDecorator
constructor
A new instance of DelegateDecorator.
Constructor Details
#initialize(subject, options = {}) ⇒ DelegateDecorator
Returns a new instance of DelegateDecorator.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sugar-high/delegate.rb', line 44 def initialize(subject, = {}) [:only] ||= [] [:except] ||= [] [:only].map!(&:to_s) [:except].map!(&:to_s) meths = subject.public_methods(false) meths = meths & [:only] unless [:only].empty? meths.each do |meth| (class << self; self; end).class_eval do unless [:except].include? meth.to_s define_method meth do |*args| subject.send meth, *args end end end end end |