def serialize(value)
        case value
        when Array
          return ActiveSupport::JSON.encode(value) if value.empty? || value.any? { |v| !v.is_a?(StoreModel::Model) }

          ActiveSupport::JSON.encode(value,
                                     serialize_unknown_attributes: value.first.serialize_unknown_attributes?,
                                     serialize_enums_using_as_json: value.first.serialize_enums_using_as_json?)
        else
          super
        end
      end
Casts a value from the ruby type to a type that the database knows how
to understand.

@param value [Object] value to serialize

@return [String] serialized value