Module: Anise::Annotator
- Defined in:
- lib/anise/annotator.rb
Overview
Annotator
The Annotator module allows for the creation of method annotations which attach to the next method defined.
This idiom of annotator-before-definition was popularized by Rake’s desc/task pair. The Annotator module makes it very easy to add similar capabilites to any program.
require 'anise/annotator'
class X
include Anise::Annotator
annotator :doc
doc "See what I mean?"
def see
puts "Yes, I see!"
end
end
X.ann(:see, :doc) #=> "See what I mean?"
Note that the library uses the #method_added callback, so be sure to respect good practices of calling super
if you need to override this method while using Annotator.
– TODO: Allow annotators to be inherited via module mixins.
TODO: Ensure thread-safety of @_pending_annotations
variable. ++
Defined Under Namespace
Modules: Aid
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
41 42 43 44 |
# File 'lib/anise/annotator.rb', line 41 def self.included(base) base.send(:include, Annotation) #unless base.is_a?(Annotation) base.extend Aid end |