Class: GraphqlDevise::MountMethod::OptionSanitizers::StringChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_devise/mount_method/option_sanitizers/string_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_string = nil) ⇒ StringChecker

Returns a new instance of StringChecker.



7
8
9
# File 'lib/graphql_devise/mount_method/option_sanitizers/string_checker.rb', line 7

def initialize(default_string = nil)
  @default_string = default_string
end

Instance Method Details

#call!(value, key) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/graphql_devise/mount_method/option_sanitizers/string_checker.rb', line 11

def call!(value, key)
  return @default_string if value.blank?

  unless value.instance_of?(String)
    raise InvalidMountOptionsError, "`#{key}` option has an invalid value. String expected."
  end

  value
end