Class: GraphqlDevise::MountMethod::OptionSanitizers::HashChecker
- Inherits:
-
Object
- Object
- GraphqlDevise::MountMethod::OptionSanitizers::HashChecker
- Defined in:
- lib/graphql_devise/mount_method/option_sanitizers/hash_checker.rb
Instance Method Summary collapse
- #call!(value, key) ⇒ Object
-
#initialize(element_type_array) ⇒ HashChecker
constructor
A new instance of HashChecker.
Constructor Details
#initialize(element_type_array) ⇒ HashChecker
Returns a new instance of HashChecker.
7 8 9 10 |
# File 'lib/graphql_devise/mount_method/option_sanitizers/hash_checker.rb', line 7 def initialize(element_type_array) @element_type_array = Array(element_type_array) @default_value = {} end |
Instance Method Details
#call!(value, key) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/graphql_devise/mount_method/option_sanitizers/hash_checker.rb', line 12 def call!(value, key) return @default_value if value.blank? unless value.instance_of?(Hash) raise InvalidMountOptionsError, "`#{key}` option has an invalid value. Hash expected. Got #{value.class}." end value.each { |internal_key, klass| ClassChecker.new(@element_type_array).call!(klass, "#{key} -> #{internal_key}") } value end |