/**
* -------------------------------------------------------------------------------
* Classe Storage 1.0
* 	Visa a organização dos dados. Baseada nas seguintes classes:
*	  - 'generic' de David Walsh (http://davidwalsh.name/php-generic-objects-organize-code-class/)
*	  - 'MixedCollection' da biblioteca ExtJS 2.0
* -------------------------------------------------------------------------------
* Criado em....: 29/02/2008
* Alterado em..: -
* -------------------------------------------------------------------------------
* Changelog
* -------------------------------------------------------------------------------
*/

var Storage = new Class({
	
	initialize: function(hMyItems){
		return {Store: {
			
			$items: $H(hMyItems),
			
			clear: function(){
				return this.$items.empty();
			},
			
			contains: function(sValue){
				return this.$items.values().contains(sValue);
			},
			
			containsKey: function(sKey){
				return this.$items.hasKey(sKey);
			},
			
			get: function(sKey){
				return this.$items.get(sKey);
			},
			
			getAll: function(){
				return this.$items;
			},
			
			getCount: function(){
				return this.$items.values().length;
			},
			
			load: function(hVars){
				return this.$items.extend(hVars);
			},
			
			replace: function(sKey, sValue){
				this.$items.set(sKey, sValue);
				return sValue;
			},
			
			set: function(sKey, sValue, bReplaceIfExists){
				if(this.containsKey(sKey) && !bReplaceIfExists)
					return false;
				
				return this.replace(sKey, sValue);
			},
			
			unset: function(sKey){
				return this.$items.remove(sKey);
			}
			
		}};
	}
	
});