■
ロギングや同期処理をアスペクトにまとめる。
require 'thread' require 'aspectr' include AspectR class MutexArary < Array attr_reader :mutex def initialize @mutex = Mutex.new end end class MutexArrayAspect < Aspect def lock(method, object, status, *args) object.mutex.lock end def unlock(method, object, status, *args) object.mutex.unlock end end mutex_aspect = MutexArrayAspect.new mutex_aspect.wrap(MutexArray, :lock, :unlock, /\<\