class GraphqlDevise::MountMethod::OptionSanitizers::HashChecker

Public Class Methods

new(element_type_array) click to toggle source
# 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

Public Instance Methods

call!(value, key) click to toggle source
# 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 GraphqlDevise::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