1 /**
  2  *
  3  * object
  4  * @fileOverView core/object
  5  * @author  <a href="mailto:zhang.gd@foxmail.com">Zhang Guangda</a>
  6  * @date    2012-10-25
  7  */
  8 define("core/object", function() {
  9 	/**
 10 	 * @class we object方法
 11 	 */
 12 	$we.object = {
 13 		/**
 14 		 * 将第二个object的属性merge到第一个object中去
 15 		 * @param  {object} a      需要得到的object
 16 		 * @param  {object} b      需要merge到a里面的object
 17 		 * @param  {bool}   bCover 是否覆盖
 18 		 * @return {object}        a
 19 		 */
 20 		merge: function(a, b, bCover) {
 21 			bCover = $we.utils.setValue("bCover", true);
 22 			if (typeof a != 'object' || typeof b != 'object')
 23 				return a;
 24 
 25 			for (var i in b) {
 26 				if (typeof a[i] == "undefined" || bCover)
 27 					a[i] = b[i];
 28 			}
 29 
 30 			return a;
 31 		},
 32 
 33 		/**
 34 		 * 根据路径获取object的data
 35 		 * @param  {object} data Object
 36 		 * @param  {string} path 路径
 37 		 */
 38 		getValue: function(data, path) {
 39 			if(!data){
 40 				return null;
 41 			}
 42 			if(typeof path == "string"){
 43 				path = path.split(".");
 44 			}
 45 			for(var i=0;i<path.length;++i){
 46 				try{
 47 					data = data[path[i]];
 48 				}catch(e){
 49 					return null;
 50 				}
 51 			}
 52 			return data;
 53 		}
 54 	};
 55 
 56 	return $we.object;
 57 });