lib/surrealist/type_helper.rb
# Checks if value returned from a method is an instance of type class specified
# in schema or NilClass.
#
# @param [any] value value returned from a method.
# @param [Class] type class representing data type.
#
# @return [boolean]
Checks if value returned from a method is an instance of type class specified
in schema or NilClass.
Checks if value returned from a method is an instance of type class specified in schema or NilClass .
def valid_type?(value, type)
        return true if type == Any
        if type == Bool
          Surrealist::Carrier::BOOLEANS.include?(value)
        elsif defined?(Dry::Types) && dry_type?(type)
          type.try(value).success?
        else
          value.nil? || value.is_a?(type)
        end
      end
def valid_type? ( value , type ) return true if type == Any if type == Bool Surrealist :: Carrier :: BOOLEANS . include? ( value ) elsif defined? ( Dry :: Types ) && dry_type? ( type ) type . try ( value ) . success? else value . nil? || value . is_a? ( type ) end end
Checks if value returned from a method is an instance of type class specified
in schema or NilClass.
Checks if value returned from a method is an instance of type class specified in schema or NilClass .
None
boolean
value
<not_specific>
type
<not_specific>
<not_specific>
type class representing data type.
type class representing data type .