/**
 * All intellectual property rights in this Software throughout the world belong to UK Radioplayer, 
 * rights in the Software are licensed (not sold) to subscriber stations, and subscriber stations 
 * have no rights in, or to, the Software other than the right to use it in accordance with the 
 * Terms and Conditions at www.radioplayer.co.uk/terms. You shall not produce any derivate works 
 * based on whole or part of the Software, including the source code, for any other purpose other 
 * than for usage associated with connecting to the UK Radioplayer Service in accordance with these 
 * Terms and Conditions, and you shall not convey nor sublicense the Software, including the source 
 * code, for any other purpose or to any third party, without the prior written consent of UK Radioplayer.
 *
 * @name Datastore
 * @description Stores data received from webservice
 *
 *
 * @author Cathy Bartlett <cathy.bartlett@bbc.co.uk>
 */

radioplayer.services.Datastore = function(data) {
	this._data = data || {};
};

radioplayer.services.Datastore.prototype = {
    _data: {},

    addData: function(obj) {
		//append new data
		for (id in obj) {
			if (id in this._data) {
				this._data[id] = glow.lang.apply(obj[id], this._data[id]);
			}
			else {
				this._data[id] = glow.lang.clone(obj[id]);
			}
		}
	},
	
	isInDatastore: function(id) {
		return id in this._data;
	},

    get: function(id) {
        if (id in this._data) {
            return this._data[id];
        }
    }

};

