Class: Topoisomerase::Comments
- Inherits:
-
Object
- Object
- Topoisomerase::Comments
- Defined in:
- lib/topoisomerase/comments.rb
Overview
Class to set up comments that will be added to stubs for dynamic methods
Class Attribute Summary collapse
-
.inheriting_class ⇒ Object
Class for which stubs will be created from and for which rules to add comments for are defined.
Class Method Summary collapse
-
.add_for_class(inheriting_class, &script) ⇒ Object
Add comments according to matchers for an inheriting class.
-
.comment(comment, matchers) ⇒ Object
Add a comment that is returned if ALL matchers are true.
Class Attribute Details
.inheriting_class ⇒ Object
Returns Class for which stubs will be created from and for which rules to add comments for are defined.
7 8 9 |
# File 'lib/topoisomerase/comments.rb', line 7 def inheriting_class @inheriting_class end |
Class Method Details
.add_for_class(inheriting_class, &script) ⇒ Object
Add comments according to matchers for an inheriting class
The order in which they are added is the order in which matching will occur. The first comment that has a match will be used. If several matchers are used on 1 comment, all must be true to be considered a match
34 35 36 37 38 |
# File 'lib/topoisomerase/comments.rb', line 34 def add_for_class(inheriting_class, &script) Topoisomerase.comments_added[inheriting_class] ||= [] self.inheriting_class = inheriting_class instance_eval(&script) end |
.comment(comment, matchers) ⇒ Object
Add a comment that is returned if ALL matchers are true
14 15 16 17 18 19 |
# File 'lib/topoisomerase/comments.rb', line 14 def comment(comment, matchers) Topoisomerase.comments_added[inheriting_class] << { message: comment, matchers: matchers } end |