Module: TopSecret::Mapping
- Included in:
- Text::BatchResult, Text::Result, Text::ScanResult
- Defined in:
- lib/top_secret/mapping.rb
Overview
Provides dynamic category methods for querying sensitive information by type.
This module automatically generates methods for accessing sensitive information organized by category (emails, credit cards, people, etc.). Methods are available for all default filter types and any custom labels used in the mapping.
Instance Method Summary collapse
-
#categories ⇒ Array<Symbol>
Returns categories that have matches in the mapping.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
-
#safe? ⇒ Boolean
Whether sensitive information was not found.
-
#sensitive? ⇒ Boolean
Whether sensitive information was found.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/top_secret/mapping.rb', line 43 def method_missing(method_name, *args, &block) category = category_for(method_name) if category result = category.resolve(method_name, mapping) define_singleton_method(method_name) { result } result else super end end |
Instance Method Details
#categories ⇒ Array<Symbol>
Returns categories that have matches in the mapping.
62 63 64 |
# File 'lib/top_secret/mapping.rb', line 62 def categories @categories ||= category_objects.select { |c| c.matches?(mapping) }.map { |c| c.type.to_sym } end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
55 56 57 |
# File 'lib/top_secret/mapping.rb', line 55 def respond_to_missing?(method_name, include_private = false) category_for(method_name) || super end |
#safe? ⇒ Boolean
Returns Whether sensitive information was not found.
39 40 41 |
# File 'lib/top_secret/mapping.rb', line 39 def safe? !sensitive? end |
#sensitive? ⇒ Boolean
Returns Whether sensitive information was found.
34 35 36 |
# File 'lib/top_secret/mapping.rb', line 34 def sensitive? mapping.any? end |