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)



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/simple-annotations.rb', line 63

def method_missing(meth, *args)
  return super unless /\A§/ =~ meth

  @last_annotations ||= {}
  @last_annotations[meth[1..].to_sym] = if args.empty?
                                          true
                                        elsif args.size == 1
                                          args.first
                                        else
                                          args
                                        end
end

Instance Method Details

#annotations(meth = nil) ⇒ Object



49
50
51
52
53
# File 'lib/simple-annotations.rb', line 49

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

  AnnotationMonitor.registered[to_s.to_sym]
end