Method: Anise::Annotative::Methods#method_added

Defined in:
lib/anise/annotative/methods.rb

#method_added(sym) ⇒ Object

When a method is added, run all pending annotations.

Parameters:

  • The name of the method added.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/anise/annotative/methods.rb', line 105

def method_added(sym)
  annotations = Methods.pending_annotations[self]
  annotations.each do |anns, block|
    if block
      block.call(sym)
    else
      anns.each do |name, value|
        if name.to_s.index('/')
          name, ns = name.to_s.split('/')
        else
          ns = :ann
        end
        ann(sym/ns, name=>value)
      end
    end
  end
  Methods.pending_annotations[self] = []
  super if defined?(super)
end