Module: Anise::Annotator::Aid
- Defined in:
- lib/anise/annotator.rb
Instance Method Summary collapse
-
#annotator(name, &block) ⇒ Object
Define an annotator.
-
#method_added(sym) ⇒ Object
When a method is added, run all pending annotations.
Instance Method Details
#annotator(name, &block) ⇒ Object
Define an annotator.
49 50 51 52 53 54 55 56 |
# File 'lib/anise/annotator.rb', line 49 def annotator(name, &block) (class << self; self; end).module_eval do define_method(name) do |*args| @_pending_annotations ||= [] @_pending_annotations << [name, args, block] end end end |
#method_added(sym) ⇒ Object
When a method is added, run all pending annotations.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/anise/annotator.rb', line 59 def method_added(sym) @_pending_annotations ||= [] @_pending_annotations.each do |name, args, block| if block block.call(sym, *args) else if args.size == 1 ann(sym, name=>args.first) else ann(sym, name=>args) end end end @_pending_annotations = [] super if defined?(super) end |