Class: InputSanitizer::V2::NestedSanitizerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/input_sanitizer/v2/nested_sanitizer_factory.rb

Defined Under Namespace

Classes: HashExpected, NilAllowed

Class Method Summary collapse

Class Method Details

.for(nested_sanitizer_klass, value, options) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/input_sanitizer/v2/nested_sanitizer_factory.rb', line 30

def self.for(nested_sanitizer_klass, value, options)
  if value.nil? && options[:allow_nil] && !options[:collection]
    NilAllowed.new
  elsif !value.is_a?(Hash)
    HashExpected.new(value)
  else
    nested_sanitizer_klass.new(value, options)
  end
end