Class: GraphqlDevise::MountMethod::OptionSanitizers::BooleanChecker

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

Instance Method Summary collapse

Constructor Details

#initialize(default_boolean = nil) ⇒ BooleanChecker

Returns a new instance of BooleanChecker.



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

def initialize(default_boolean = nil)
  @default_boolean = default_boolean
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/boolean_checker.rb', line 11

def call!(value, key)
  return @default_boolean if value.nil?

  unless value.instance_of?(TrueClass) || value.instance_of?(FalseClass)
    raise InvalidMountOptionsError, "`#{key}` option has an invalid value. `true` or `false` expected."
  end

  value
end