Sha256: 9824d998dfc995d2889f76048de9e096b2c1b8f21d292f894dbfbe171299c38b

Contents?: true

Size: 744 Bytes

Versions: 9

Compression:

Stored size: 744 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
graphql_devise-0.12.3 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.12.2 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.12.1 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.12.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.11.4 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.11.3 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.11.2 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.11.1 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb
graphql_devise-0.11.0 lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb