Sha256: 9b4d78a78fc19ffa58f9e23ea03902a3f1fd5d66600462da13f1221d238e07cc

Contents?: true

Size: 775 Bytes

Versions: 18

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module GraphqlDevise
  module MountMethod
    module OptionSanitizers
      class ClassChecker
        def initialize(klass)
          @klass_array = Array(klass)
        end

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

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

          unless @klass_array.any? { |klass| value.ancestors.include?(klass) }
            raise GraphqlDevise::InvalidMountOptionsError,
                  "`#{key}` option has an invalid value. #{@klass_array.join(', ')} or descendants expected. Got #{value}."
          end

          value
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
graphql_devise-0.18.2 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.18.1 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.18.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.17.1 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.17.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.16.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.15.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.14.3 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.14.2 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.14.1 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.14.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.6 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.5 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.4 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.3 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.2 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.1 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.13.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb