Module: AttributesSanitizer::Sanitizers
- Included in:
- AttributesSanitizer
- Defined in:
- lib/attributes_sanitizer/sanitizers.rb
Instance Method Summary collapse
Instance Method Details
#define_sanitizer(sanitizer_name, &block) ⇒ Object
4 5 6 7 8 |
# File 'lib/attributes_sanitizer/sanitizers.rb', line 4 def define_sanitizer(sanitizer_name, &block) @sanitizers ||= {} raise ArgumentError, 'sanitizer needs a block' unless block_given? @sanitizers[sanitizer_name.to_sym] = block end |
#find(sanitizer_name) ⇒ Object
10 11 12 13 14 |
# File 'lib/attributes_sanitizer/sanitizers.rb', line 10 def find(sanitizer_name) sanitizer = @sanitizers && @sanitizers[sanitizer_name.to_sym] raise ArgumentError, "No sanitizer defined for #{sanitizer_name}" if sanitizer.nil? sanitizer end |