Rake 里 desc 方法的简单实现
Opened this issue · 0 comments
manxingxing commented
module Annotation
def desc(description)
@_last_description = description
end
def method_added(method_name)
description = get_last_description
descriptions[method_name.to_sym] = description if description
super
end
def get_last_description
description = @_last_description
@_last_description = nil
description
end
def descriptions
@_descriptions ||= {}
end
end
class A
extend Annotation
desc 'foo method'
def foo
end
end