Module: Annotations::ClassMethods

Defined in:
lib/simple-annotations.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object (private)



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/simple-annotations.rb', line 55

def method_missing(meth, *args)
  return super unless /\A§/ =~ meth
  @last_annotations ||= {}
  if args.size == 0
    @last_annotations[meth[1..-1].to_sym] = true 
  elsif args.size == 1
    @last_annotations[meth[1..-1].to_sym] = args.first
  else
    @last_annotations[meth[1..-1].to_sym] = args
  end
end

Instance Method Details

#annotations(meth = nil) ⇒ Object



41
42
43
44
45
# File 'lib/simple-annotations.rb', line 41

def annotations(meth=nil)
   
  return AnnotationMonitor::registered[self.class.to_s.to_sym][meth] if meth
  AnnotationMonitor::registered[self.to_s.to_sym]
end