<commit_before>import { A } from '@ember/array';
import { warn } from '@ember/debug';
import { get, set } from '@ember/object';
import Mixin from '@ember/object/mixin';
import { camelize } from '@ember/string';
import { typeOf } from '@ember/utils';

/**
  @module @ember-data/serializer
*/

/**
  ## Using Embedded Records

  `EmbeddedRecordsMixin` supports serializing embedded records.

  To set up embedded records, include the mixin when extending a serializer,
  then define and configure embedded (model) relationships.

  Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.

  Below is an example of a per-type serializer (`post` type).

  ```app/serializers/post.js
  import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';

  export default RESTSerializer.extend(EmbeddedRecordsMixin, {
    attrs: {
      author: { embedded: 'always' },
      comments: { serialize: 'ids' }
    }
  });
  ```
  Note that this use of `{ embedded: 'always' }` is unrelated to
  the `{ embedded: 'always' }` that is defined as an option on `attr` as part of
  defining a model while working with the `ActiveModelSerializer`.  Nevertheless,
  using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up
  embedded records.

  The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:

  ```js
  {
    serialize: 'records',
    deserialize: 'records'
  }
  ```
<commit_msg>Update embedded-records-mixin.js documentation<commit_after>import { A } from '@ember/array';
import { warn } from '@ember/debug';
import { get, set } from '@ember/object';
import Mixin from '@ember/object/mixin';
import { camelize } from '@ember/string';
import { typeOf } from '@ember/utils';

/**
  @module @ember-data/serializer
*/

/**
  ## Using Embedded Records

  `EmbeddedRecordsMixin` supports serializing embedded records.

  To set up embedded records, include the mixin when extending a serializer,
  then define and configure embedded (model) relationships.

  Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.

  Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.

  Below is an example of a per-type serializer (`post` type).

  ```app/serializers/post.js
  import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';

  export default RESTSerializer.extend(EmbeddedRecordsMixin, {
    attrs: {
      author: { embedded: 'always' },
      comments: { serialize: 'ids' }
    }
  });
  ```
  Note that this use of `{ embedded: 'always' }` is unrelated to
  the `{ embedded: 'always' }` that is defined as an option on `attr` as part of
  defining a model while working with the `ActiveModelSerializer`.  Nevertheless,
  using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up
  embedded records.

  The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:

  ```js
  {
    serialize: 'records',
    deserialize: 'records'
  }
  ```

{'fraction_non_alphanumeric': 0.10816708229426433, 'fraction_numerical': 0.0, 'mean_word_length': 3.8768996960486324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4151976', 'n_tokens_mistral': 940, 'n_tokens_neox': 905, 'n_words': 360}