Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# uses the Decorator module on my blog post # I'm also using ActiveSupport's Inflector to save time, but you get the idea require 'active_support' class Symbol def to_class Kernel.const_get(Inflector::camelize(self)) end end class Whip include Decorator end class Milk include Decorator end class Sprinkles include Decorator end class Coffee def self.with(*extras) extras.inject(self.new) { |drink, extra| drink = extra.to_class.new(drink) } end end # simple coffee Coffee.new # coffee with milk, whip and sprinkles Coffee.with :milk, :whip, :sprinkles
This paste will be private.
From the Design Piracy series on my blog: