nano-store 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README.md +8 -4
  2. data/Rakefile +1 -1
  3. data/lib/nano_store.rb +2 -4
  4. data/lib/nano_store/version.rb +1 -1
  5. data/spec/model_spec.rb +14 -0
  6. data/spec/spec_helper.rb +4 -0
  7. data/vendor/Podfile.lock +4 -4
  8. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals.h +3 -1
  9. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoPredicate.h +5 -5
  10. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSearch.h +5 -3
  11. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSortDescriptor.h +1 -1
  12. data/vendor/Pods/BuildHeaders/NanoStore/NanoStore.h +36 -0
  13. data/vendor/Pods/Documentation/NanoStore/docset-installed.txt +2 -2
  14. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Info.plist +3 -3
  15. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoBag.html +2 -2
  16. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoEngine.html +2 -2
  17. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoExpression.html +2 -2
  18. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoObject.html +2 -2
  19. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoPredicate.html +7 -7
  20. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoResult.html +2 -2
  21. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoSearch.html +66 -5
  22. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoSortDescriptor.html +3 -3
  23. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoStore.html +2 -2
  24. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFOrderedDictionary.html +2 -2
  25. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Protocols/NSFNanoObjectProtocol.html +2 -2
  26. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/css/styles.css +0 -0
  27. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/hierarchy.html +5 -5
  28. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/index.html +5 -5
  29. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Nodes.xml +1 -1
  30. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens5.xml +6 -6
  31. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens7.xml +24 -2
  32. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens8.xml +2 -2
  33. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.dsidx +0 -0
  34. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.skidx +0 -0
  35. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.toc +0 -0
  36. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoBag.html +2 -2
  37. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoEngine.html +2 -2
  38. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoExpression.html +2 -2
  39. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoObject.html +2 -2
  40. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoPredicate.html +7 -7
  41. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoResult.html +2 -2
  42. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoSearch.html +66 -5
  43. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoSortDescriptor.html +3 -3
  44. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoStore.html +2 -2
  45. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFOrderedDictionary.html +2 -2
  46. data/vendor/Pods/Documentation/NanoStore/html/Protocols/NSFNanoObjectProtocol.html +2 -2
  47. data/vendor/Pods/Documentation/NanoStore/html/css/styles.css +0 -0
  48. data/vendor/Pods/Documentation/NanoStore/html/hierarchy.html +5 -5
  49. data/vendor/Pods/Documentation/NanoStore/html/index.html +5 -5
  50. data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals.h +3 -1
  51. data/vendor/Pods/Headers/NanoStore/NSFNanoPredicate.h +5 -5
  52. data/vendor/Pods/Headers/NanoStore/NSFNanoSearch.h +5 -3
  53. data/vendor/Pods/Headers/NanoStore/NSFNanoSortDescriptor.h +1 -1
  54. data/vendor/Pods/Headers/NanoStore/NanoStore.h +36 -0
  55. data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.m +40 -49
  56. data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.m +42 -53
  57. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.m +80 -89
  58. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.m +11 -13
  59. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.h +3 -1
  60. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.m +1 -0
  61. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m +34 -29
  62. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.h +5 -5
  63. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.m +43 -34
  64. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.h +5 -3
  65. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.m +171 -97
  66. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.h +1 -1
  67. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.m +13 -12
  68. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.m +92 -86
  69. data/vendor/Pods/NanoStore/Classes/Public/NanoStore.h +36 -0
  70. data/vendor/Pods/Pods-resources.sh +8 -4
  71. data/vendor/Pods/Pods.bridgesupport +109 -101
  72. metadata +5 -5
@@ -27,16 +27,17 @@
27
27
  #import "NSFNanoResult.h"
28
28
  #import "NanoStore_Private.h"
29
29
 
30
- @implementation NSFNanoResult
31
- {
32
- @protected
33
- /** \cond */
34
- NSDictionary *results;
35
- /** \endcond */
36
- }
30
+ @interface NSFNanoResult ()
31
+
32
+ /** \cond */
33
+ @property (nonatomic, assign, readwrite) NSUInteger numberOfRows;
34
+ @property (nonatomic, strong, readwrite) NSError *error;
35
+ @property (nonatomic) NSDictionary *results;
36
+ /** \endcond */
37
37
 
38
- @synthesize numberOfRows;
39
- @synthesize error;
38
+ @end
39
+
40
+ @implementation NSFNanoResult
40
41
 
41
42
  /** \cond */
42
43
 
@@ -57,24 +58,24 @@
57
58
 
58
59
  - (NSString *)description
59
60
  {
60
- NSUInteger numberOfColumns = [[results allKeys]count];
61
+ NSUInteger numberOfColumns = [[_results allKeys]count];
61
62
 
62
63
  NSMutableString *description = [NSMutableString string];
63
64
  [description appendString:@"\n"];
64
65
  [description appendString:[NSString stringWithFormat:@"Result address : %p\n", self]];
65
66
  [description appendString:[NSString stringWithFormat:@"Number of columns : %ld\n", numberOfColumns]];
66
- if (nil == error)
67
+ if (nil == _error)
67
68
  if ([[self columns]count] > 0)
68
69
  [description appendString:[NSString stringWithFormat:@"Columns : %@\n", [[self columns]componentsJoinedByString:@", "]]];
69
70
  else
70
71
  [description appendString:[NSString stringWithFormat:@"Columns : %@\n", @"()"]];
71
72
  else
72
73
  [description appendString:[NSString stringWithFormat:@"Columns : %@\n", @"<column info not available>"]];
73
- [description appendString:[NSString stringWithFormat:@"Number of rows : %ld\n", numberOfRows]];
74
- if (nil == error)
74
+ [description appendString:[NSString stringWithFormat:@"Number of rows : %ld\n", _numberOfRows]];
75
+ if (nil == _error)
75
76
  [description appendString:[NSString stringWithFormat:@"Error : %@\n", @"<no error>"]];
76
77
  else
77
- [description appendString:[NSString stringWithFormat:@"Error : %@\n", [error localizedDescription]]];
78
+ [description appendString:[NSString stringWithFormat:@"Error : %@\n", [_error localizedDescription]]];
78
79
 
79
80
  // Print up to the first ten rows to help visualize the cursor
80
81
  if (0 != numberOfColumns) {
@@ -105,11 +106,11 @@
105
106
  }
106
107
 
107
108
  // Print the preview of the contents
108
- if (numberOfRows > 0) {
109
- NSInteger numberOfRowsToPrint = numberOfRows;
109
+ if (_numberOfRows > 0) {
110
+ NSInteger numberOfRowsToPrint = _numberOfRows;
110
111
  NSUInteger j;
111
112
 
112
- if (numberOfRows > 100) {
113
+ if (_numberOfRows > 100) {
113
114
  numberOfRowsToPrint = 100;
114
115
  }
115
116
 
@@ -141,13 +142,13 @@
141
142
 
142
143
  - (NSFOrderedDictionary *)dictionaryDescription
143
144
  {
144
- NSUInteger numberOfColumns = [[results allKeys]count];
145
+ NSUInteger numberOfColumns = [[_results allKeys]count];
145
146
 
146
147
  NSFOrderedDictionary *values = [NSFOrderedDictionary new];
147
148
 
148
149
  values[@"Result address"] = [NSString stringWithFormat:@"%p", self];
149
150
  values[@"Number of columns"] = @(numberOfColumns);
150
- if (nil == error) {
151
+ if (nil == _error) {
151
152
  if ([[self columns]count] > 0) {
152
153
  values[@"Columns"] = [[self columns]componentsJoinedByString:@", "];
153
154
  } else {
@@ -156,11 +157,11 @@
156
157
  } else {
157
158
  values[@"Columns"] = @"<column info not available>";
158
159
  }
159
- values[@"Number of rows"] = @(numberOfRows);
160
- if (nil == error) {
160
+ values[@"Number of rows"] = @(_numberOfRows);
161
+ if (nil == _error) {
161
162
  values[@"Error"] = @"<nil>";
162
163
  } else {
163
- values[@"Error"] = [NSString stringWithFormat:@"%@", [error localizedDescription]];
164
+ values[@"Error"] = [NSString stringWithFormat:@"%@", [_error localizedDescription]];
164
165
  }
165
166
 
166
167
  // Print up to the first ten rows to help visualize the cursor
@@ -196,11 +197,11 @@
196
197
  [printedContent addObject:[contentString copy]];
197
198
 
198
199
  // Print the preview of the contents
199
- if (numberOfRows > 0) {
200
- NSInteger numberOfRowsToPrint = numberOfRows;
200
+ if (_numberOfRows > 0) {
201
+ NSInteger numberOfRowsToPrint = _numberOfRows;
201
202
  NSUInteger j;
202
203
 
203
- if (numberOfRows > 100) {
204
+ if (_numberOfRows > 100) {
204
205
  numberOfRowsToPrint = 100;
205
206
  }
206
207
 
@@ -251,17 +252,17 @@
251
252
 
252
253
  - (NSArray *)columns
253
254
  {
254
- return [results allKeys];
255
+ return [_results allKeys];
255
256
  }
256
257
 
257
258
  - (NSString *)valueAtIndex:(NSUInteger)index forColumn:(NSString *)column
258
259
  {
259
- return [[results objectForKey:column]objectAtIndex:index];
260
+ return [[_results objectForKey:column]objectAtIndex:index];
260
261
  }
261
262
 
262
263
  - (NSArray *)valuesForColumn:(NSString *)column
263
264
  {
264
- NSArray *values = [results objectForKey:column];
265
+ NSArray *values = [_results objectForKey:column];
265
266
 
266
267
  if (nil == values)
267
268
  values = [NSArray array];
@@ -271,22 +272,17 @@
271
272
 
272
273
  - (NSString *)firstValue
273
274
  {
274
- NSArray *columns = [results allKeys];
275
- if (([columns count] > 0) && (numberOfRows > 0)) {
276
- return [[results objectForKey:[columns objectAtIndex:0]]objectAtIndex:0];
275
+ NSArray *columns = [_results allKeys];
276
+ if (([columns count] > 0) && (_numberOfRows > 0)) {
277
+ return [[_results objectForKey:[columns objectAtIndex:0]]objectAtIndex:0];
277
278
  }
278
279
 
279
280
  return nil;
280
281
  }
281
282
 
282
- - (NSError *)error
283
- {
284
- return [error copy];
285
- }
286
-
287
283
  - (void)writeToFile:(NSString *)path;
288
284
  {
289
- [results writeToFile:[path stringByExpandingTildeInPath] atomically:YES];
285
+ [_results writeToFile:[path stringByExpandingTildeInPath] atomically:YES];
290
286
  }
291
287
 
292
288
  #pragma mark - Private Methods
@@ -316,7 +312,7 @@
316
312
  userInfo:nil]raise];
317
313
 
318
314
  if ((self = [self init])) {
319
- results = theResults;
315
+ _results = theResults;
320
316
  [self _calculateNumberOfRows];
321
317
  }
322
318
 
@@ -336,36 +332,29 @@
336
332
  userInfo:nil]raise];
337
333
 
338
334
  if ((self = [self init])) {
339
- error = theError;
335
+ _error = theError;
340
336
  [self _calculateNumberOfRows];
341
337
  }
342
338
 
343
339
  return self;
344
340
  }
345
341
 
346
- - (void)_setError:(NSError *)theError
347
- {
348
- if (error != theError) {
349
- error = theError;
350
- }
351
- }
352
-
353
342
  - (void)_reset
354
343
  {
355
- numberOfRows = -1;
356
- results = nil;
357
- error = nil;
344
+ _numberOfRows = -1;
345
+ _results = nil;
346
+ _error = nil;
358
347
  }
359
348
 
360
349
  - (void)_calculateNumberOfRows
361
350
  {
362
351
  // We cache the value once, for performance reasons
363
- if (-1 == numberOfRows) {
364
- NSArray *allKeys = [results allKeys];
352
+ if (-1 == _numberOfRows) {
353
+ NSArray *allKeys = [_results allKeys];
365
354
  if ([allKeys count] == 0)
366
- numberOfRows = 0;
355
+ _numberOfRows = 0;
367
356
  else
368
- numberOfRows = [[results objectForKey:[allKeys lastObject]]count];
357
+ _numberOfRows = [[_results objectForKey:[allKeys lastObject]]count];
369
358
  }
370
359
  }
371
360
  /** \endcond */
@@ -35,16 +35,13 @@
35
35
 
36
36
  @implementation NSFNanoBag
37
37
  {
38
- @protected
39
38
  /** \cond */
40
- NSMutableDictionary *savedObjects;
41
- NSMutableDictionary *unsavedObjects;
42
- NSMutableDictionary *removedObjects;
39
+ NSMutableDictionary *_savedObjects;
40
+ NSMutableDictionary *_unsavedObjects;
41
+ NSMutableDictionary *_removedObjects;
43
42
  /** \endcond */
44
43
  }
45
44
 
46
- @synthesize store, name, key, savedObjects, unsavedObjects, removedObjects, hasUnsavedChanges;
47
-
48
45
  + (NSFNanoBag*)bag
49
46
  {
50
47
  return [[self alloc]initBagWithName:nil andObjects:[NSArray array]];
@@ -76,8 +73,8 @@
76
73
  if ((self = [self init])) {
77
74
  [self addObjectsFromArray:someObjects error:nil];
78
75
 
79
- name = [theName copy];
80
- hasUnsavedChanges = YES;
76
+ _name = theName;
77
+ _hasUnsavedChanges = YES;
81
78
  }
82
79
 
83
80
  return self;
@@ -88,13 +85,13 @@
88
85
  - (id)init
89
86
  {
90
87
  if ((self = [super init])) {
91
- store = nil;
92
- key = [NSFNanoEngine stringWithUUID];
93
- savedObjects = [NSMutableDictionary new];
94
- unsavedObjects = [NSMutableDictionary new];
95
- removedObjects = [NSMutableDictionary new];
96
-
97
- hasUnsavedChanges = NO;
88
+ _store = nil;
89
+ _key = [NSFNanoEngine stringWithUUID];
90
+ _name = nil;
91
+ _savedObjects = [NSMutableDictionary new];
92
+ _unsavedObjects = [NSMutableDictionary new];
93
+ _removedObjects = [NSMutableDictionary new];
94
+ _hasUnsavedChanges = NO;
98
95
  }
99
96
 
100
97
  return self;
@@ -102,7 +99,7 @@
102
99
 
103
100
  - (id)copyWithZone:(NSZone *)zone
104
101
  {
105
- NSFNanoBag *copy = [[[self class]allocWithZone:zone]initNanoObjectFromDictionaryRepresentation:[self dictionaryRepresentation] forKey:[NSFNanoEngine stringWithUUID] store:store];
102
+ NSFNanoBag *copy = [[[self class]allocWithZone:zone]initNanoObjectFromDictionaryRepresentation:[self dictionaryRepresentation] forKey:[NSFNanoEngine stringWithUUID] store:_store];
106
103
  return copy;
107
104
  }
108
105
 
@@ -116,20 +113,15 @@
116
113
 
117
114
  - (void)setName:(NSString *)aName
118
115
  {
119
- name = [aName copy];
120
- hasUnsavedChanges = YES;
116
+ _name = aName;
117
+ _hasUnsavedChanges = YES;
121
118
  }
122
119
 
123
120
  /** \endcond */
124
121
 
125
- - (NSString *)name
126
- {
127
- return name;
128
- }
129
-
130
122
  - (NSUInteger)count
131
123
  {
132
- return savedObjects.count + unsavedObjects.count;
124
+ return _savedObjects.count + _unsavedObjects.count;
133
125
  }
134
126
 
135
127
  - (NSString *)description
@@ -142,13 +134,13 @@
142
134
  NSFOrderedDictionary *values = [NSFOrderedDictionary new];
143
135
 
144
136
  values[@"NanoBag address"] = [NSString stringWithFormat:@"%p", self];
145
- values[@"Key"] = key;
146
- values[@"Name"] = (nil != name) ? name : @"<untitled>";
147
- values[@"Document store"] = ([store dictionaryDescription] ? [store dictionaryDescription] : @"<nil>");
148
- values[@"Has unsaved changes?"] = (hasUnsavedChanges ? @"YES" : @"NO");
149
- values[@"Saved objects"] = @([savedObjects count]);
150
- values[@"Unsaved objects"] = @([unsavedObjects count]);
151
- values[@"Removed objects"] = @([removedObjects count]);
137
+ values[@"Key"] = _key;
138
+ values[@"Name"] = (nil != _name) ? _name : @"<untitled>";
139
+ values[@"Document store"] = ([_store dictionaryDescription] ? [_store dictionaryDescription] : @"<nil>");
140
+ values[@"Has unsaved changes?"] = (_hasUnsavedChanges ? @"YES" : @"NO");
141
+ values[@"Saved objects"] = @([_savedObjects count]);
142
+ values[@"Unsaved objects"] = @([_unsavedObjects count]);
143
+ values[@"Removed objects"] = @([_removedObjects count]);
152
144
 
153
145
  return values;
154
146
  }
@@ -167,17 +159,17 @@
167
159
  {
168
160
  // Iterate the objects collecting the object keys
169
161
  NSMutableArray *objectKeys = [NSMutableArray new];
170
- for (NSString *objectKey in self.savedObjects) {
162
+ for (NSString *objectKey in _savedObjects) {
171
163
  [objectKeys addObject:objectKey];
172
164
  }
173
- for (NSString *objectKey in self.unsavedObjects) {
165
+ for (NSString *objectKey in _unsavedObjects) {
174
166
  [objectKeys addObject:objectKey];
175
167
  }
176
168
 
177
169
  NSMutableDictionary *info = [NSMutableDictionary dictionary];
178
170
 
179
- if (nil != name) {
180
- [info setObject:name forKey:NSF_Private_NSFNanoBag_Name];
171
+ if (nil != _name) {
172
+ [info setObject:_name forKey:NSF_Private_NSFNanoBag_Name];
181
173
  }
182
174
  [info setObject:self.key forKey:NSF_Private_NSFNanoBag_NSFKey];
183
175
  [info setObject:objectKeys forKey:NSF_Private_NSFNanoBag_NSFObjectKeys];
@@ -193,17 +185,17 @@
193
185
 
194
186
  BOOL success = YES;
195
187
 
196
- NSArray *sortedArraySelf = [[[self savedObjects]allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
188
+ NSArray *sortedArraySelf = [[_savedObjects allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
197
189
  NSArray *sortedArrayOther = [[[otherNanoBag savedObjects]allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
198
190
  if (NO == [sortedArraySelf isEqualToArray:sortedArrayOther]) {
199
191
  success = NO;
200
192
  } else {
201
- sortedArraySelf = [[[self unsavedObjects]allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
193
+ sortedArraySelf = [[_unsavedObjects allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
202
194
  sortedArrayOther = [[[otherNanoBag unsavedObjects]allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
203
195
  if (NO == [sortedArraySelf isEqualToArray:sortedArrayOther]) {
204
196
  success = NO;
205
197
  } else {
206
- sortedArraySelf = [[[self removedObjects]allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
198
+ sortedArraySelf = [[_removedObjects allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
207
199
  sortedArrayOther = [[[otherNanoBag removedObjects]allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
208
200
  if (NO == [sortedArraySelf isEqualToArray:sortedArrayOther]) {
209
201
  success = NO;
@@ -228,10 +220,10 @@
228
220
  NSDictionary *info = [(id)object dictionaryRepresentation];
229
221
 
230
222
  if (objectKey && info) {
231
- [savedObjects removeObjectForKey:objectKey];
232
- [unsavedObjects setObject:object forKey:objectKey];
233
- [removedObjects removeObjectForKey:objectKey];
234
- hasUnsavedChanges = YES;
223
+ [_savedObjects removeObjectForKey:objectKey];
224
+ [_unsavedObjects setObject:object forKey:objectKey];
225
+ [_removedObjects removeObjectForKey:objectKey];
226
+ _hasUnsavedChanges = YES;
235
227
  } else {
236
228
  NSString *message = nil;
237
229
  if (nil == objectKey)
@@ -281,21 +273,20 @@
281
273
 
282
274
  - (void)removeAllObjects
283
275
  {
284
- NSMutableDictionary *objects = [[NSMutableDictionary alloc]initWithCapacity:(savedObjects.count + removedObjects.count)];
276
+ NSMutableDictionary *objects = [[NSMutableDictionary alloc]initWithCapacity:(_savedObjects.count + _removedObjects.count)];
285
277
 
286
278
  // Save the object and its key
287
- for (id object in savedObjects) {
279
+ for (id object in _savedObjects) {
288
280
  [objects setObject:object forKey:[object performSelector:@selector(key)]];
289
281
  }
290
282
 
291
283
  // Save the previously removed objects (if any)
292
- [objects addEntriesFromDictionary:removedObjects];
293
-
294
- [savedObjects removeAllObjects];
295
- [unsavedObjects removeAllObjects];
296
- [removedObjects setDictionary:objects];
297
- hasUnsavedChanges = YES;
284
+ [objects addEntriesFromDictionary:_removedObjects];
298
285
 
286
+ [_savedObjects removeAllObjects];
287
+ [_unsavedObjects removeAllObjects];
288
+ [_removedObjects setDictionary:objects];
289
+ _hasUnsavedChanges = YES;
299
290
  }
300
291
 
301
292
  - (void)removeObjectsInArray:(NSArray *)someObjects
@@ -314,22 +305,22 @@
314
305
  }
315
306
 
316
307
  // Is the object an existing one?
317
- id object = [savedObjects objectForKey:objectKey];
308
+ id object = [_savedObjects objectForKey:objectKey];
318
309
  if (nil != object) {
319
- [savedObjects removeObjectForKey:objectKey];
310
+ [_savedObjects removeObjectForKey:objectKey];
320
311
  } else {
321
312
  // Is the object still unsaved?
322
- object = [unsavedObjects objectForKey:objectKey];
313
+ object = [_unsavedObjects objectForKey:objectKey];
323
314
  if (nil != object) {
324
- [unsavedObjects removeObjectForKey:objectKey];
315
+ [_unsavedObjects removeObjectForKey:objectKey];
325
316
  }
326
317
  }
327
318
 
328
319
  if (nil == object) {
329
320
  // The object doesn't exist, so there is no need to mark the bag as dirty
330
321
  } else {
331
- [removedObjects setObject:object forKey:objectKey];
332
- hasUnsavedChanges = YES;
322
+ [_removedObjects setObject:object forKey:objectKey];
323
+ _hasUnsavedChanges = YES;
333
324
  }
334
325
  }
335
326
 
@@ -346,7 +337,7 @@
346
337
  return YES;
347
338
  }
348
339
 
349
- if (nil == store) {
340
+ if (nil == _store) {
350
341
  if (nil != outError) {
351
342
  *outError = [NSError errorWithDomain:NSFDomainKey
352
343
  code:NSFNanoStoreErrorKey
@@ -356,42 +347,42 @@
356
347
  return NO;
357
348
  }
358
349
 
359
- return [self _saveInStore:store error:outError];
350
+ return [self _saveInStore:_store error:outError];
360
351
  }
361
352
 
362
353
  #pragma mark -
363
354
 
364
355
  - (void)deflateBag
365
356
  {
366
- NSArray *savedObjectsCopy = [[NSArray alloc]initWithArray:[savedObjects allKeys]];
357
+ NSArray *savedObjectsCopy = [[NSArray alloc]initWithArray:[_savedObjects allKeys]];
367
358
 
368
359
  for (id saveObjectKey in savedObjectsCopy) {
369
- [savedObjects setObject:[NSNull null] forKey:saveObjectKey];
360
+ [_savedObjects setObject:[NSNull null] forKey:saveObjectKey];
370
361
  }
371
362
 
372
363
  }
373
364
 
374
365
  - (void)inflateBag
375
366
  {
376
- NSArray *objectKeys = [savedObjects allKeys];
367
+ NSArray *objectKeys = [_savedObjects allKeys];
377
368
  [self _inflateObjectsWithKeys:objectKeys];
378
369
  }
379
370
 
380
371
  - (BOOL)reloadBagWithError:(out NSError **)outError
381
372
  {
382
373
  // If the bag is not associated to a document store, there is no need to continue
383
- if (nil == store) {
374
+ if (nil == _store) {
384
375
  return YES;
385
376
  }
386
377
 
387
378
  // Refresh the bag to match the contents stored on the database
388
- [self _inflateObjectsWithKeys:[NSArray arrayWithObject:key]];
389
- NSFNanoBag *savedBag = [savedObjects objectForKey:key];
379
+ [self _inflateObjectsWithKeys:[NSArray arrayWithObject:_key]];
380
+ NSFNanoBag *savedBag = [_savedObjects objectForKey:_key];
390
381
  if (nil != savedBag) {
391
- [savedObjects removeAllObjects];
392
- [savedObjects addEntriesFromDictionary:savedBag.savedObjects];
393
- for (NSString *objectKey in unsavedObjects) {
394
- [savedObjects removeObjectForKey:objectKey];
382
+ [_savedObjects removeAllObjects];
383
+ [_savedObjects addEntriesFromDictionary:savedBag.savedObjects];
384
+ for (NSString *objectKey in _unsavedObjects) {
385
+ [_savedObjects removeObjectForKey:objectKey];
395
386
  }
396
387
  } else {
397
388
  if (nil != outError) {
@@ -408,11 +399,11 @@
408
399
 
409
400
  - (BOOL)undoChangesWithError:(out NSError **)outError
410
401
  {
411
- [savedObjects removeAllObjects];
412
- [unsavedObjects removeAllObjects];
413
- [removedObjects removeAllObjects];
402
+ [_savedObjects removeAllObjects];
403
+ [_unsavedObjects removeAllObjects];
404
+ [_removedObjects removeAllObjects];
414
405
 
415
- hasUnsavedChanges = NO;
406
+ _hasUnsavedChanges = NO;
416
407
 
417
408
  return [self reloadBagWithError:outError];
418
409
  }
@@ -426,18 +417,18 @@
426
417
  - (id)initNanoObjectFromDictionaryRepresentation:(NSDictionary *)dictionary forKey:(NSString *)aKey store:(NSFNanoStore *)aStore
427
418
  {
428
419
  if ((self = [self init])) {
429
- name = [[dictionary objectForKey:NSF_Private_NSFNanoBag_Name]copy];
430
- store = aStore;
431
- key = aKey;
432
- savedObjects = [NSMutableDictionary new];
433
- unsavedObjects = [NSMutableDictionary new];
434
- removedObjects = [NSMutableDictionary new];
420
+ _name = [dictionary objectForKey:NSF_Private_NSFNanoBag_Name];
421
+ _store = aStore;
422
+ _key = aKey;
423
+ _savedObjects = [NSMutableDictionary new];
424
+ _unsavedObjects = [NSMutableDictionary new];
425
+ _removedObjects = [NSMutableDictionary new];
435
426
 
436
427
  NSArray *objectKeys = [dictionary objectForKey:NSF_Private_NSFNanoBag_NSFObjectKeys];
437
428
 
438
429
  [self _inflateObjectsWithKeys:objectKeys];
439
430
 
440
- hasUnsavedChanges = NO;
431
+ _hasUnsavedChanges = NO;
441
432
  }
442
433
 
443
434
  return self;
@@ -450,35 +441,35 @@
450
441
 
451
442
  - (NSString *)nanoObjectKey
452
443
  {
453
- return key;
444
+ return _key;
454
445
  }
455
446
 
456
447
  - (void)_setStore:(NSFNanoStore *)aStore
457
448
  {
458
- store = aStore;
449
+ _store = aStore;
459
450
  }
460
451
 
461
452
  - (BOOL)_saveInStore:(NSFNanoStore *)someStore error:(out NSError **)outError
462
453
  {
463
454
  // Save the unsaved objects first...
464
- NSArray *contentsToBeSaved = [unsavedObjects allValues];
455
+ NSArray *contentsToBeSaved = [_unsavedObjects allValues];
465
456
  if ([contentsToBeSaved count] > 0) {
466
457
  [someStore _addObjectsFromArray:contentsToBeSaved forceSave:YES error:outError];
467
458
  }
468
459
 
469
460
  // Move the existing objects to the unsaved list, in order to save the bag
470
- [unsavedObjects addEntriesFromDictionary:savedObjects];
471
- [savedObjects removeAllObjects];
472
- [removedObjects removeAllObjects];
461
+ [_unsavedObjects addEntriesFromDictionary:_savedObjects];
462
+ [_savedObjects removeAllObjects];
463
+ [_removedObjects removeAllObjects];
473
464
 
474
465
  // Save the unsaved bag...
475
466
  BOOL success = [someStore _addObjectsFromArray:[NSArray arrayWithObject:self] forceSave:YES error:outError];
476
467
 
477
468
  if (YES == success) {
478
- [unsavedObjects removeAllObjects];
469
+ [_unsavedObjects removeAllObjects];
479
470
  success = [self reloadBagWithError:outError];
480
471
  if (YES == success) {
481
- hasUnsavedChanges = NO;
472
+ _hasUnsavedChanges = NO;
482
473
  }
483
474
  return success;
484
475
  }
@@ -489,14 +480,14 @@
489
480
  - (void)_inflateObjectsWithKeys:(NSArray *)someKeys
490
481
  {
491
482
  if ([someKeys count] != 0) {
492
- NSFNanoSearch *search = [NSFNanoSearch searchWithStore:store];
483
+ NSFNanoSearch *search = [NSFNanoSearch searchWithStore:_store];
493
484
  NSString *quotedString = [NSFNanoSearch _quoteStrings:someKeys joiningWithDelimiter:@","];
494
485
  NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT NSFKey, NSFKeyedArchive, NSFObjectClass FROM NSFKeys WHERE NSFKey IN (%@)", quotedString];
495
486
 
496
487
  NSDictionary *results = [search executeSQL:theSQLStatement returnType:NSFReturnObjects error:nil];
497
488
 
498
489
  if (nil != results) {
499
- [savedObjects addEntriesFromDictionary:results];
490
+ [_savedObjects addEntriesFromDictionary:results];
500
491
  }
501
492
  }
502
493
  }