2.8. Interceptor Block

When a block is passed to the s2aspect method, the block is treated as Interceptor. The argument to the block is MethodInvocation instance. By calling the proceed method of MethodInvocation class, following Interceptor or the method for Aspect is executed.

require 's2container'

class Action
  s2comp
  def index
    s2logger.debug(self){"Action::index called."}
    return 100
  end
end

s2aspect(:pattern => Action) {|invocation|
  invocation.proceed * 1.05
}

p s2app[Action].index  # -> 105.0
[Note]NOTE

This Example is located at "examples/quickstart/quickstart7".



© Copyright The Seasar Foundation and the others 2008-2009, all rights reserved.