Fixes typos and ensures type safety

This commit is contained in:
Muhammad Nawzad 2023-11-17 15:59:52 +03:00
parent 26ec4d9214
commit dc89944058
No known key found for this signature in database
GPG Key ID: B954B6AAE33940B2
3 changed files with 5 additions and 5 deletions

View File

@ -62,7 +62,7 @@ module Schemable
attribute_hash = @model.fields[attribute.to_s]
# Check if this attribute has a custom JSON Schema definition
return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute)
return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute.to_sym)
return @model_definition.additional_response_attributes[attribute] if @model_definition.additional_response_attributes.keys.include?(attribute)
# Check if this is an array attribute
@ -81,7 +81,7 @@ module Schemable
attribute_hash = @model.columns_hash[attribute.to_s]
# Check if this attribute has a custom JSON Schema definition
return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute)
return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute.to_sym)
return @model_definition.additional_response_attributes[attribute] if @model_definition.additional_response_attributes.keys.include?(attribute)
# Check if this is an array attribute

View File

@ -17,7 +17,7 @@ module Schemable
:enum_prefix_for_simple_enum,
:enum_suffix_for_simple_enum,
:infer_attributes_from_custom_method,
:infer_attributes_from_jsonapi_serializable,
:infer_attributes_from_jsonapi_serializable
)
# Initializes a new Configuration instance with default values.
@ -46,7 +46,7 @@ module Schemable
# @param type_name [Symbol, String] The name of the type.
# @return [Hash] The type mapper for the given type name.
def type_mapper(type_name)
return @custom_type_mappers[type_name] if @custom_type_mappers.key?(type_name)
return @custom_type_mappers[type_name] if @custom_type_mappers.key?(type_name.to_sym)
{
text: { type: :string },

View File

@ -3,7 +3,7 @@ module Schemable
# It includes methods for handling attributes, relationships, and various request and response attributes.
# The definition class is meant to be inherited by a class that represents a model.
# This class should be configured to match the model's attributes and relationships.
# The defaullt configuration is set in this class, but can be overridden in the model's definition class.
# The default configuration is set in this class, but can be overridden in the model's definition class.
#
# @see Schemable
class Definition