Class: Karafka::Web::Pro::Ui::Lib::Search::Matchers::Base
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Ui::Lib::Search::Matchers::Base
- Defined in:
- lib/karafka/web/pro/ui/lib/search/matchers/base.rb
Overview
Base class for all the search matchers Each matcher needs to have a class ‘#name` method and needs to respond to `#call`
Direct Known Subclasses
Class Method Summary collapse
-
.active?(_topic_name) ⇒ Boolean
Allows to disable/enable certain matches that may be specific to certain types of data per topic.
-
.name ⇒ String
Name of the matcher based on the class name.
Instance Method Summary collapse
-
#call(phrase, message) ⇒ Boolean
True if found, otherwise false.
Class Method Details
.active?(_topic_name) ⇒ Boolean
Allows to disable/enable certain matches that may be specific to certain types of data per topic. By default matchers are always active
65 66 67 |
# File 'lib/karafka/web/pro/ui/lib/search/matchers/base.rb', line 65 def active?(_topic_name) true end |
.name ⇒ String
Returns name of the matcher based on the class name.
52 53 54 55 56 57 58 |
# File 'lib/karafka/web/pro/ui/lib/search/matchers/base.rb', line 52 def name # Insert a space before each uppercase letter, except the first one spaced_string = to_s.split("::").last.gsub(/(?<!^)([A-Z])/, ' \1') # Convert the first letter to uppercase and the rest to lowercase spaced_string[0].upcase + spaced_string[1..].downcase end |
Instance Method Details
#call(phrase, message) ⇒ Boolean
Returns true if found, otherwise false.
46 47 48 |
# File 'lib/karafka/web/pro/ui/lib/search/matchers/base.rb', line 46 def call(phrase, ) raise NotImplementedError, "Implement in a subclass" end |