Ruby aspectr 例子的错误

chenge · 2013年03月16日 · 1857 次阅读

require 'aspectr'

class Example < Object
    def do_sth
        p 'do sth'
    end
end

class Logger < AspectR::Aspect
    def log_enter(method, object, exitstatus, *args)
        p "enter #{method}"
    end
    def log_exit(method, object, exitstatus, *args)
        p "exit #{method}"
    end
end

Logger.new.wrap(Example, :log_enter, :log_exit, :do_sth)

e = Example.new
e.do_sth

运行有错,如果 wrap 设置一个 nil,就可以。 想知道有没有类似这个 aspectr 的?

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号