Class: Quickdraw::Registry
- Inherits:
-
Object
- Object
- Quickdraw::Registry
- Defined in:
- lib/quickdraw/registry.rb
Instance Method Summary collapse
-
#expectation_for(value, matchers: nil) ⇒ Object
Given a value, find or build an expectation class that includes all the matchers for the value.
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#register(matcher, *types) ⇒ Object
Register a new matcher for the given types.
Constructor Details
Instance Method Details
#expectation_for(value, matchers: nil) ⇒ Object
Given a value, find or build an expectation class that includes all the matchers for the value.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/quickdraw/registry.rb', line 22 def expectation_for(value, matchers: nil) if matchers shape_for( matchers + matchers_for(value) ) else shape_for( matchers_for(value) ) end end |
#register(matcher, *types) ⇒ Object
Register a new matcher for the given types.
14 15 16 17 18 19 |
# File 'lib/quickdraw/registry.rb', line 14 def register(matcher, *types) @registered_matchers[matcher] = types # We need to clear this cache because the output of `slowly_find_matchers_for` might have changed. @type_matchers.clear end |