<commit_before>'use strict';

var Ember = require('ember'),
	Promise = Ember.RSVP.Promise,
	PromiseObject = require('./promiseobject'),
	PromiseArray = require('./promisearray'),
	Model = require('./model'),
	DataLight = require('./index');

var CachedModel = module.exports = DataLight.CachedModel = Model.extend({
	__dataChanged: function() {
		var Model = this.constructor;
		var id = this.get(Model.primaryKey);

		if(typeof id === 'undefined') {
			return;
		}

		var cacheID = Model._computeCacheID(id);
		if(Model.existsInCache(cacheID)) {
			return;
		}

		Model.addToCache(cacheID, this);
	}.observes('__data').on('init'),

	copy: function() {
		var model = this.constructor.create();
		var properties = this.getProperties(['__data', '__attributes', 'isNew', 'isDeleted']);
		var propertiesCopy = {
			__data: Ember.$.extend({}, properties.__data),
			__attributes: Ember.$.extend({}, properties.__attributes),
			isNew: properties.isNew,
			isDeleted: properties.isDeleted
		};

		model.setProperties(propertiesCopy);
		return model;
	},

	
});

CachedModel.reopenClass({
	cache: true,
	cacheItems: {},
	cacheSize: 0,
	cacheMax: null,
	cacheQueries: true,

	_computeCacheID: function(id) {
		if(!id) {
			return null;
		}

		if(!this.type) {
			throw new Error('Model type is not defined');
		}

		return this.type + '-' + id;
	},<commit_msg>ie typo<commit_after>'use strict';

var Ember = require('ember'),
	Promise = Ember.RSVP.Promise,
	PromiseObject = require('./promiseobject'),
	PromiseArray = require('./promisearray'),
	Model = require('./model'),
	DataLight = require('./index');

var CachedModel = module.exports = DataLight.CachedModel = Model.extend({
	__dataChanged: function() {
		var Model = this.constructor;
		var id = this.get(Model.primaryKey);

		if(typeof id === 'undefined') {
			return;
		}

		var cacheID = Model._computeCacheID(id);
		if(Model.existsInCache(cacheID)) {
			return;
		}

		Model.addToCache(cacheID, this);
	}.observes('__data').on('init'),

	copy: function() {
		var model = this.constructor.create();
		var properties = this.getProperties(['__data', '__attributes', 'isNew', 'isDeleted']);
		var propertiesCopy = {
			__data: Ember.$.extend({}, properties.__data),
			__attributes: Ember.$.extend({}, properties.__attributes),
			isNew: properties.isNew,
			isDeleted: properties.isDeleted
		};

		model.setProperties(propertiesCopy);
		return model;
	}
});

CachedModel.reopenClass({
	cache: true,
	cacheItems: {},
	cacheSize: 0,
	cacheMax: null,
	cacheQueries: true,

	_computeCacheID: function(id) {
		if(!id) {
			return null;
		}

		if(!this.type) {
			throw new Error('Model type is not defined');
		}

		return this.type + '-' + id;
	},
{'fraction_non_alphanumeric': 0.1651818856718634, 'fraction_numerical': 0.0007423904974016332, 'mean_word_length': 4.273972602739726, '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': '7176439', 'n_tokens_mistral': 974, 'n_tokens_neox': 889, 'n_words': 185}