Class BooleanTransform
Defined in: warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:6
The BooleanTransform class is used to serialize and deserialize boolean attributes on Ember Data record objects. This transform is used when 'boolean' is passed as the type parameter to the attrfunction.
Usage
import { Model, attr } from '@warp-drive/legacy/model';
export default class UserModel extends Model {
@attr('boolean') isAdmin;
@attr('string') name;
@attr('string') email;
}By default, the boolean transform only allows for values of true or false. You can opt into allowing null values for boolean attributes via attr('boolean', { allowNull: true })
import { Model, attr } from '@warp-drive/legacy/model';
export default class UserModel extends Model {
@attr('string') email;
@attr('string') username;
@attr('boolean', { allowNull: true }) wantsWeeklyEmail;
}Constructors
Constructor
new BooleanTransform(): BooleanTransform;Returns
BooleanTransform
Methods
deserialize()
deserialize(serialized, options?): boolean | null;Defined in: warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:52
Converts a serialized (raw payload) value into a boolean (or null when allowNull is set and the value is nullish).
Parameters
serialized
string | number | boolean | null
options?
allowNull?
boolean
Returns
boolean | null
serialize()
serialize(deserialized, options?): boolean | null;Defined in: warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:71
Converts a boolean attribute value into its serialized (raw payload) form.
Parameters
deserialized
boolean | null
options?
allowNull?
boolean
Returns
boolean | null
create()
static create(): BooleanTransform;Defined in: warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:82
Creates a new instance of this transform.
Returns
BooleanTransform
Properties
___(unique) Symbol($type)
___(unique) Symbol($type): "boolean";Defined in: warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:10
see TransformName