Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
module Decorator def decorate(obj, &block) extender = Module.new extender.module_eval(&block) obj.extend extender obj end module_function :decorate end a = [] Decorator.decorate(a) { def push(*args) puts "They are pushing stuff on us *again*!" super end } a.push 1, 2, 3
This paste will be private.
From the Design Piracy series on my blog: