]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/platform/src/data/sync/Utilities.js
4 delegate: function(from_instance
, to_instance
, methods
) {
5 if (to_instance
===undefined) { throw "Error - Tried to delegate '"+methods
+"' to undefined instance."; }
6 methods
.forEach(function(method
){
7 var to_method
= to_instance
[method
];
8 if (to_method
===undefined) { throw "Error - Tried to delegate undefined method '"+method
+"' to "+to_instance
; }
9 from_instance
[method
]= function() {
10 return to_method
.apply(to_instance
, arguments
);
15 apply: function(instance
,methods
,a
,done_callback
,done_scope
) {
17 Ext
.data
.array
.forEachAsync(methods
,function(method
,next_callback
,next_scope
){
19 a
.push(next_callback
);
23 instance
[method
].apply(instance
,a
);
24 },instance
,done_callback
,done_scope
);
27 copy: function(from_instance
,to_instance
,properties
) {
29 properties
.forEach(function(property
){
30 var from_v
= from_instance
[property
];
31 var to_v
= to_instance
[property
];
32 if (from_v
!==undefined && from_v
!==to_v
) {
33 to_instance
[property
]= from_v
;
40 copyIfUndefined: function(from_instance
,to_instance
,properties
) {
42 properties
.forEach(function(property
){
43 var from_v
= from_instance
[property
];
44 var to_v
= to_instance
[property
];
45 if (from_v
!==undefined && to_v
===undefined) {
46 to_instance
[property
]= from_v
;
53 check: function(class_name
, method_name
, instance_name
, instance
, properties
) {
54 if (instance
===undefined) {
55 var message
= "Error - "+class_name
+"."+method_name
+" - "+instance_name
+" not provided.";
59 properties
.forEach(function(property
) {
60 var value
= instance
[property
];
61 if (value
===undefined) {
62 var message
= "Error - "+class_name
+"."+method_name
+" - "+instance_name
+"."+property
+" not provided.";
70 minus: function(a
,b
) { // minus(a,b) is all the name value pairs in a that are not in b
73 if (a
.hasOwnProperty(n
)) {
74 if (b
[n
]===undefined) {
82 intersection: function(a
,b
) {
85 if (a
.hasOwnProperty(n
)) {
86 if (b
[n
]!==undefined) {