A Scala-style "with" Construct for Ruby

screenshot

Scala has a “mixin” construct called traits, which are roughly analogous to Ruby modules. They allow you to create reusable, modular bits of state and behavior and use them to compose classes and other traits or modules. The syntax for using Scala traits is quite elegant. It’s straightforward to implement the same syntax in Ruby and doing so has a few useful advantages. For example, here is a Scala example that uses a trait to trace calls to a Worker.work method. // run with "scala example...

http://blog.objectmentor.com/articles/2008/09/29/a-scala-style-_with_-construct-for-ruby

withでinstanceをnewするときにtraitをmixin

http://b.hatena.ne.jp/entry/http://blog.objectmentor.com/articles/2008/09/29/a-scala-style-_with_-construct-for-ruby