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
48 49 50 |
# File 'lib/karafka/web/pro/ui/lib/search/matchers/base.rb', line 48 def active?(_topic_name) true end |
.name ⇒ String
Returns name of the matcher based on the class name.
35 36 37 38 39 40 41 |
# File 'lib/karafka/web/pro/ui/lib/search/matchers/base.rb', line 35 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.
29 30 31 |
# File 'lib/karafka/web/pro/ui/lib/search/matchers/base.rb', line 29 def call(phrase, ) raise NotImplementedError, 'Implement in a subclass' end |