forked from soveran/cuba
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make class_matcher and symbol_matcher plugin be able to build on top …
…of existing registered matchers This makes it significantly simpler to use existing matchers to create more powerful matchers. For example, you can build an Employee matcher that uses the conversion from the Integer matcher, and then looks up the related id. class_matcher Employee, Integer do |id| Employee[id] end You can mix the class and symbol matchers, for more specific matching. This is helpful when you don't have separate classes for everything you want to match. For example, if you want to match only active employees, you can have a symbol_matcher that builds on top of the Employee class matcher: symbol_matcher :ActiveEmployee, Employee |employee| employee if employee.active? end In order to work with the Integer_matcher_max plugin without significant slowdown, this duplicates the integer conversion code at the application class level. In order for the symbol matchers generated from class matchers to work with the placeholder_string_matchers plugin, this has both symbol matchers and class matchers store both the base and full regexps used for matching. This also speeds up the symbol_matcher by caching the symbol matcher at the class level, instead of having to perform a cache lookup during every match.
- Loading branch information
1 parent
bec99de
commit e0854b9
Showing
8 changed files
with
465 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.