Class: FixtureRecord::Sanitizable::Registry
- Inherits:
-
Object
- Object
- FixtureRecord::Sanitizable::Registry
- Defined in:
- lib/fixture_record/sanitizable.rb
Class Method Summary collapse
- .[] ⇒ Object
- .deregister(klass_or_symbol) ⇒ Object
- .fetch(to_be_matched) ⇒ Object
- .register_sanitizer(klass, as: nil) ⇒ Object
- .sanitize_pattern(pattern, with:) ⇒ Object
Class Method Details
.[] ⇒ Object
27 28 29 |
# File 'lib/fixture_record/sanitizable.rb', line 27 def self.[](...) @_fixture_record_sanitizer_name_registry.send(:[], ...) end |
.deregister(klass_or_symbol) ⇒ Object
31 32 33 |
# File 'lib/fixture_record/sanitizable.rb', line 31 def self.deregister(klass_or_symbol) @_fixture_record_sanitizer_pattern_registry.delete_if { |pattern, with| with == klass_or_symbol } end |
.fetch(to_be_matched) ⇒ Object
43 44 45 |
# File 'lib/fixture_record/sanitizable.rb', line 43 def self.fetch(to_be_matched) @_fixture_record_sanitizer_pattern_registry.select { |pattern, value| to_be_matched.match(pattern) }.map(&:last) end |
.register_sanitizer(klass, as: nil) ⇒ Object
39 40 41 |
# File 'lib/fixture_record/sanitizable.rb', line 39 def self.register_sanitizer(klass, as: nil) @_fixture_record_sanitizer_name_registry[as.to_sym] = klass.new end |
.sanitize_pattern(pattern, with:) ⇒ Object
35 36 37 |
# File 'lib/fixture_record/sanitizable.rb', line 35 def self.sanitize_pattern(pattern, with:) @_fixture_record_sanitizer_pattern_registry << [pattern, with] end |