<commit_before>import Ember from 'ember';
import EmptyObject from '../util/empty-object';

const {
  get,
  on
} = Ember;

export default Ember.Mixin.create({

  _createCollectionIdentity: on('init', function() {
    this._collectionIdentity = new EmptyObject();
  }),

  _serializeCollectionOpts(opts) {
    return JSON.stringify(opts);
  },

  _collectionIdentifier(collectionClass, opts) {
    if(!opts) {
      opts = null;
    }
    let modelName = get(collectionClass, 'modelName');
    let serializedOpts = this._serializeCollectionOpts(opts);
    return `${modelName} ${serializedOpts}`;
  },

  _existingCollectionForIdentifier(identifier) {
    return this._collectionIdentity[identifier];
  },

  _onInternalCollectionCreatedForIdentifier(identifier, internal) {
    this._collectionIdentity[identifier] = internal;
    return internal;
  },

  _onInternalCollectionDestroyed(internal) {
    let identifier = this._collectionIdentifier(internal.collectionClass, internal.opts);
    delete this._collectionIdentity[identifier];
  }

});<commit_msg>have _collectionIdentity with all and initial objects<commit_after>import Ember from 'ember';
import EmptyObject from '../util/empty-object';

const {
  get,
  on
} = Ember;

export default Ember.Mixin.create({

  _createCollectionIdentity: on('init', function() {
    this._collectionIdentity = new EmptyObject();
    this._collectionIdentity.all = new EmptyObject();
    this._collectionIdentity.initial = new EmptyObject();
  }),

  _setCollectionIdentityInitialState(identifier, state) {
    this._collectionIdentity.initial[identifier] = state;
  },

  _popCollectionIdentityInitialState(identifier) {
    let state = this._collectionIdentity.initial[identifier];
    delete this._collectionIdentity.initial[identifier];
    return state;
  },

  _serializeCollectionOpts(opts) {
    return JSON.stringify(opts);
  },

  _collectionIdentifier(collectionClass, opts) {
    if(!opts) {
      opts = null;
    }
    let modelName = get(collectionClass, 'modelName');
    let serializedOpts = this._serializeCollectionOpts(opts);
    return `${modelName} ${serializedOpts}`;
  },

  _existingCollectionForIdentifier(identifier) {
    return this._collectionIdentity.all[identifier];
  },

  _onInternalCollectionCreatedForIdentifier(identifier, internal) {
    this._collectionIdentity.all[identifier] = internal;
    return internal;
  },

  _onInternalCollectionDestroyed(internal) {
    let identifier = this._collectionIdentifier(internal.collectionClass, internal.opts);
    delete this._collectionIdentity.all[identifier];
  }

});
{'fraction_non_alphanumeric': 0.11093990755007704, 'fraction_numerical': 0.0, 'mean_word_length': 4.771111111111111, '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': '2271505', 'n_tokens_mistral': 708, 'n_tokens_neox': 699, 'n_words': 134}