Module: Annotations
- Defined in:
- lib/simple-annotations.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
the version of simple_annotations
Version.current
- RESERVED_ANNOTATIONS =
%i[after before].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
11 12 13 |
# File 'lib/simple-annotations.rb', line 11 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#annotations(meth = nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/simple-annotations.rb', line 15 def annotations(meth = nil) annotation = AnnotationMonitor.registered[self.class.to_s.to_sym] return annotation[meth] if meth annotation end |
#fields(meth = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/simple-annotations.rb', line 36 def fields(meth = nil) if meth annotations(meth).except(*RESERVED_ANNOTATIONS) else res = {} annotations.each_key do |val| res[val] = annotations[val].except(*RESERVED_ANNOTATIONS) end res end end |
#hooks(meth = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simple-annotations.rb', line 22 def hooks(meth = nil) if meth annotations(meth).slice(*RESERVED_ANNOTATIONS) else res = {} annotations.each_key do |val| res[val] = annotations[val].select do |item, _val| RESERVED_ANNOTATIONS.include? item end end res end end |