class GraphqlDevise::MountMethod::OptionSanitizers::ArrayChecker
Public Class Methods
new(element_type)
click to toggle source
# File lib/graphql_devise/mount_method/option_sanitizers/array_checker.rb, line 7 def initialize(element_type) @element_type = element_type @default_value = [] end
Public Instance Methods
call!(value, key)
click to toggle source
# File lib/graphql_devise/mount_method/option_sanitizers/array_checker.rb, line 12 def call!(value, key) return @default_value if value.blank? unless value.instance_of?(Array) raise GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has an invalid value. Array expected." end unless value.all? { |element| element.instance_of?(@element_type) } raise GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has invalid elements. #{@element_type} expected." end value end