5 // Created by Sam McCall on 4/05/09.
12 @implementation Config
14 - (id)initWithName:(NSString *)name {
15 if ((self = [super init])) {
16 self.name = name ? name : @"Untitled";
17 _entries = [[NSMutableDictionary alloc] init];
22 - (Target *)objectForKeyedSubscript:(JSAction *)action {
23 return action ? _entries[action.uid] : nil;
26 - (void)setObject:(Target *)target forKeyedSubscript:(JSAction *)action {
29 _entries[action.uid] = target;
31 [_entries removeObjectForKey:action.uid];
35 - (NSDictionary *)serialize {
36 NSMutableDictionary* cfgEntries = [[NSMutableDictionary alloc] initWithCapacity:_entries.count];
37 for (id key in _entries) {
38 id serialized = [_entries[key] serialize];
40 cfgEntries[key] = serialized;
42 return @{ @"name": _name, @"entries": cfgEntries };