Class: Smartest::MatcherRegistry

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smartest/matcher_registry.rb

Instance Method Summary collapse

Constructor Details

#initializeMatcherRegistry

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_aObject



23
24
25
# File 'lib/smartest/matcher_registry.rb', line 23

def to_a
  @matcher_modules.dup
end