/[Frey]/trunk/static/lib/Joose/Storage/Unpacker.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/static/lib/Joose/Storage/Unpacker.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations)
Wed Jul 2 10:28:49 2008 UTC (15 years, 10 months ago) by dpavlin
File MIME type: application/javascript
File size: 1407 byte(s)
added upstream Joose r4755

http://code2.0beta.co.uk/moose/svn/Joose/trunk/lib
1 dpavlin 46 Class("Joose.Storage.Unpacker", {
2     classMethods: {
3     unpack: function (data) {
4     var name = data.__CLASS__;
5     if(!name) {
6     throw("Serialized data needs to include a __CLASS__ attribute.")
7     }
8     var jsName = this.packedClassNameToJSClassName(name)
9    
10     var co = this.meta.classNameToClassObject(jsName);
11    
12     return co.unpack(data)
13     },
14    
15     // Format My::Class::Name-0.01 We ignore the version
16     packedClassNameToJSClassName: function (packed) {
17     var parts = packed.split("-");
18     parts = parts[0].split("::");
19     return parts.join(".");
20     },
21    
22     jsonParseFilter: function (key, value) {
23     if(value != null && typeof value == "object" && value.__CLASS__) {
24     return Joose.Storage.Unpacker.unpack(value)
25     }
26     return value
27     },
28    
29     patchJSON: function () {
30     var orig = JSON.parse;
31     JSON.parse = function (s, filter) {
32     return orig(s, function (key, value) {
33     var val = value;
34     if(filter) {
35     val = filter(key, value)
36     }
37     return Joose.Storage.Unpacker.jsonParseFilter(key,val)
38     })
39     }
40     }
41     }
42     })

  ViewVC Help
Powered by ViewVC 1.1.26