#

API Docs for: v3.16.0-alpha.2
Show: Inherited Protected Private Deprecated

# NumberTransform Class

Extends Transform
Defined in: `../serializer/addon/-private/transforms/number.js:11`
Module: @ember-data/serializer

The `NumberTransform` class is used to serialize and deserialize numeric attributes on Ember Data record objects. This transform is used when `number` is passed as the type parameter to the attr function.

Usage

    import Model, { attr, belongsTo } from '@ember-data/model';

    export default Model.extend({
      value: attr('number'),
      player: belongsTo('player'),
      date: attr('date')
    });

- Index
- Methods

## Item Index

### Methods

- deserialize
- serialize

## Methods

### `deserialize`

(

- `serialized`
- `options`

)

Inherited from Transform: `../serializer/addon/-private/transforms/transform.js:99`

When given a serialized value from a JSON object this method must return the deserialized value for the record attribute. Example ```javascript deserialize(serialized, options) { return empty(serialized) ? null : Number(serialized); } ```

#### Parameters:

- `serialized` Object
  The serialized value
- `options` Object
  hash of options passed to `attr`

#### Returns:

The deserialized value

### `serialize`

(

- `deserialized`
- `options`

)

Inherited from Transform: `../serializer/addon/-private/transforms/transform.js:78`

When given a deserialized value from a record attribute this method must return the serialized value. Example ```javascript import { isEmpty } from '@ember/utils'; serialize(deserialized, options) { return isEmpty(deserialized) ? null : Number(deserialized); } ```

#### Parameters:

- `deserialized` Object
  The deserialized value
- `options` Object
  hash of options passed to `attr`

#### Returns:

The serialized value