Class: Smartest::MatcherRegistry
- Inherits:
-
Object
- Object
- Smartest::MatcherRegistry
- Includes:
- Enumerable
- Defined in:
- lib/smartest/matcher_registry.rb
Instance Method Summary collapse
- #add(matcher_module) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ MatcherRegistry
constructor
A new instance of MatcherRegistry.
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ MatcherRegistry
Returns a new instance of MatcherRegistry.
7 8 9 |
# File 'lib/smartest/matcher_registry.rb', line 7 def initialize @matcher_modules = [] end |
Instance Method Details
#add(matcher_module) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/smartest/matcher_registry.rb', line 11 def add(matcher_module) unless matcher_module.is_a?(Module) && !matcher_module.is_a?(Class) raise ArgumentError, "matcher must be a module" end @matcher_modules << matcher_module unless @matcher_modules.include?(matcher_module) end |
#each(&block) ⇒ Object
19 20 21 |
# File 'lib/smartest/matcher_registry.rb', line 19 def each(&block) @matcher_modules.each(&block) end |
#to_a ⇒ Object
23 24 25 |
# File 'lib/smartest/matcher_registry.rb', line 23 def to_a @matcher_modules.dup end |