mirror of
https://github.com/ditkrg/schemable.git
synced 2026-01-22 22:26:41 +00:00
Adds mongoid specific configurations
This commit is contained in:
parent
06aafcf883
commit
2b57b1ed3c
@ -9,8 +9,10 @@ module Schemable
|
||||
:disable_factory_bot,
|
||||
:use_serialized_instance,
|
||||
:custom_defined_enum_method,
|
||||
: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,
|
||||
)
|
||||
|
||||
def initialize
|
||||
@ -22,6 +24,8 @@ module Schemable
|
||||
@disable_factory_bot = true
|
||||
@use_serialized_instance = false
|
||||
@custom_defined_enum_method = nil
|
||||
@enum_prefix_for_simple_enum = nil
|
||||
@enum_suffix_for_simple_enum = nil
|
||||
@infer_attributes_from_custom_method = nil
|
||||
@infer_attributes_from_jsonapi_serializable = false
|
||||
end
|
||||
@ -32,6 +36,7 @@ module Schemable
|
||||
{
|
||||
text: { type: :string },
|
||||
string: { type: :string },
|
||||
symbol: { type: :string },
|
||||
integer: { type: :integer },
|
||||
boolean: { type: :boolean },
|
||||
date: { type: :string, format: :date },
|
||||
@ -44,6 +49,11 @@ module Schemable
|
||||
trueclass: { type: :boolean, default: true },
|
||||
falseclass: { type: :boolean, default: false },
|
||||
datetime: { type: :string, format: :'date-time' },
|
||||
big_decimal: { type: (@decimal_as_string ? :string : :number).to_s.to_sym, format: :double },
|
||||
'bson/objectid': { type: :string, format: :object_id },
|
||||
'mongoid/boolean': { type: :boolean },
|
||||
'mongoid/stringified_symbol': { type: :string },
|
||||
'active_support/time_with_zone': { type: :string, format: :date_time },
|
||||
float: {
|
||||
type: (@float_as_string ? :string : :number).to_s.to_sym,
|
||||
format: :float
|
||||
@ -65,7 +75,7 @@ module Schemable
|
||||
]
|
||||
}
|
||||
}
|
||||
}[type_name.try(:to_sym)]
|
||||
}[type_name.to_s.underscore.try(:to_sym)]
|
||||
end
|
||||
|
||||
def add_custom_type_mapper(type_name, mapping)
|
||||
|
||||
@ -6,6 +6,8 @@ module Schemable
|
||||
attr_accessor decimal_as_string: bool
|
||||
attr_accessor disable_factory_bot: bool
|
||||
attr_accessor use_serialized_instance: bool
|
||||
attr_accessor enum_prefix_for_simple_enum: String?
|
||||
attr_accessor enum_suffix_for_simple_enum: String?
|
||||
attr_accessor custom_defined_enum_method: Symbol?
|
||||
attr_accessor custom_type_mappers: Hash[Symbol, any]
|
||||
attr_accessor infer_attributes_from_jsonapi_serializable: bool
|
||||
|
||||
Loading…
Reference in New Issue
Block a user