Class: Lyra::Privacy::PIIDetector
- Inherits:
-
Object
- Object
- Lyra::Privacy::PIIDetector
- Defined in:
- lib/lyra/privacy/pii_detector.rb
Overview
Detects personally identifiable information (PII) in data
This class delegates to PamDsl::PIIDetector for the core PII detection logic, providing a unified implementation across both Lyra and PAM DSL.
Class Method Summary collapse
-
.contains_pii?(field_name) ⇒ Boolean
Check if a field contains PII.
-
.detect(attributes) ⇒ Hash
Detect PII in attributes.
-
.extract_from_event_stream(events) ⇒ Hash
Extract all PII from event stream.
-
.mask(value, pii_type) ⇒ String
Mask PII for display.
-
.sensitive?(pii_type) ⇒ Boolean
Check if a PII type is considered sensitive.
Class Method Details
.contains_pii?(field_name) ⇒ Boolean
Check if a field contains PII
32 33 34 |
# File 'lib/lyra/privacy/pii_detector.rb', line 32 def contains_pii?(field_name) PamDsl::PIIDetector.contains_pii?(field_name) end |
.detect(attributes) ⇒ Hash
Detect PII in attributes
23 24 25 |
# File 'lib/lyra/privacy/pii_detector.rb', line 23 def detect(attributes) PamDsl::PIIDetector.detect(attributes) end |
.extract_from_event_stream(events) ⇒ Hash
Extract all PII from event stream
This is a convenience wrapper around PamDsl::PIIDetector.extract_pii_from_records that provides Lyra-specific extractors for Lyra::Event objects.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/lyra/privacy/pii_detector.rb', line 59 def extract_from_event_stream(events) PamDsl::PIIDetector.extract_pii_from_records( events, attribute_extractor: ->(e) { e.attributes }, metadata_extractor: ->(e) { { event_id: e.event_id, timestamp: e., model_class: e.model_class, model_id: e.model_id } } ) end |
.mask(value, pii_type) ⇒ String
Mask PII for display
42 43 44 |
# File 'lib/lyra/privacy/pii_detector.rb', line 42 def mask(value, pii_type) PamDsl::PIIDetector.mask(value, pii_type) end |
.sensitive?(pii_type) ⇒ Boolean
Check if a PII type is considered sensitive
79 80 81 |
# File 'lib/lyra/privacy/pii_detector.rb', line 79 def sensitive?(pii_type) PamDsl::PIIDetector.sensitive?(pii_type) end |