Cleaned up the naming on RKManagedObjectStore to primaryManagedObjectContext and managedObjectContextForCurrentThread

This commit is contained in:
Blake Watters
2012-03-09 09:02:21 -05:00
parent 9b6992a166
commit 1c59f5fc1e
10 changed files with 50 additions and 50 deletions

View File

@@ -49,7 +49,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
}
@@ -63,10 +63,10 @@
mapping.primaryKeyAttribute = @"railsID";
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
[entityCache cacheObjectsForEntity:human.entity withMapping:mapping inContext:objectStore.context];
[entityCache cacheObjectsForEntity:human.entity withMapping:mapping inContext:objectStore.primaryManagedObjectContext];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
}
@@ -82,7 +82,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSManagedObject *cachedInstance = [entityCache cachedObjectForEntity:human.entity
withMapping:mapping
andPrimaryKeyValue:[NSNumber numberWithInt:1234] inContext:objectStore.context];
andPrimaryKeyValue:[NSNumber numberWithInt:1234] inContext:objectStore.primaryManagedObjectContext];
assertThat(cachedInstance, is(equalTo(human)));
}
@@ -98,17 +98,17 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
RKHuman* newHuman = [RKHuman createEntity];
newHuman.railsID = [NSNumber numberWithInt:5678];
[entityCache cacheObject:newHuman withMapping:mapping inContext:objectStore.context];
[entityCache cacheObjectsForEntity:human.entity withMapping:mapping inContext:objectStore.context];
[entityCache cacheObject:newHuman withMapping:mapping inContext:objectStore.primaryManagedObjectContext];
[entityCache cacheObjectsForEntity:human.entity withMapping:mapping inContext:objectStore.primaryManagedObjectContext];
humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(2)));
}
@@ -124,7 +124,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
RKHuman* newHuman = [RKHuman createEntity];
@@ -134,11 +134,11 @@
[entityCache cacheObject:newHuman.entity
withMapping:mapping
andPrimaryKeyValue:[NSNumber numberWithInt:5678]
inContext:objectStore.context];
[entityCache cacheObjectsForEntity:human.entity withMapping:mapping inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
[entityCache cacheObjectsForEntity:human.entity withMapping:mapping inContext:objectStore.primaryManagedObjectContext];
humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(2)));
}
@@ -154,10 +154,10 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
[entityCache expireCacheEntryForObject:human withMapping:mapping inContext:objectStore.context];
[entityCache expireCacheEntryForObject:human withMapping:mapping inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([entityCache.entityCache count], is(equalToInt(0)));
}
@@ -173,7 +173,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
[entityCache expireCacheEntryForEntity:human.entity];
@@ -193,7 +193,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil];
@@ -213,7 +213,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
RKHuman* newHuman = [RKHuman createEntity];
@@ -222,7 +222,7 @@
humanCache = [entityCache cachedObjectsForEntity:human.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(2)));
}
@@ -241,7 +241,7 @@
RKInMemoryEntityCache *entityCache = [[[RKInMemoryEntityCache alloc] init] autorelease];
NSMutableDictionary *humanCache = [entityCache cachedObjectsForEntity:humanOne.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(2)));
[humanTwo deleteEntity];
@@ -249,7 +249,7 @@
humanCache = [entityCache cachedObjectsForEntity:humanOne.entity
withMapping:mapping
inContext:objectStore.context];
inContext:objectStore.primaryManagedObjectContext];
assertThatInteger([humanCache count], is(equalToInt(1)));
}

View File

@@ -45,7 +45,7 @@
human.railsID = [NSNumber numberWithInt:1];
[objectManager.objectStore save:nil];
assertThat(objectManager.objectStore.context, is(equalTo(store.context)));
assertThat(objectManager.objectStore.primaryManagedObjectContext, is(equalTo(store.primaryManagedObjectContext)));
RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:store];
RKTestResponseLoader* responseLoader = [RKTestResponseLoader responseLoader];

View File

@@ -194,8 +194,8 @@
NSArray* cloudsData = [NSArray arrayWithObject:[NSDictionary dictionaryWithObject:@"Nimbus" forKey:@"name"]];
NSDictionary* mappableData = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"Hurricane", @"clouds", cloudsData, nil];
NSEntityDescription* entity = [NSEntityDescription entityForName:@"RKStorm" inManagedObjectContext:objectStore.context];
NSManagedObject* storm = [[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:objectStore.context];
NSEntityDescription* entity = [NSEntityDescription entityForName:@"RKStorm" inManagedObjectContext:objectStore.primaryManagedObjectContext];
NSManagedObject* storm = [[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:objectStore.primaryManagedObjectContext];
RKManagedObjectMappingOperation* operation = [[RKManagedObjectMappingOperation alloc] initWithSourceObject:mappableData destinationObject:storm mapping:stormMapping];
NSError* error = nil;
BOOL success = [operation performMapping:&error];

View File

@@ -152,11 +152,11 @@
[[[mockCacheStrategy expect] andForwardToRealObject] findInstanceOfEntity:OCMOCK_ANY
withMapping:mapping
andPrimaryKeyValue:@"blake"
inManagedObjectContext:objectStore.context];
inManagedObjectContext:objectStore.primaryManagedObjectContext];
[[[mockCacheStrategy expect] andForwardToRealObject] findInstanceOfEntity:mapping.entity
withMapping:mapping
andPrimaryKeyValue:@"rachit"
inManagedObjectContext:objectStore.context];
inManagedObjectContext:objectStore.primaryManagedObjectContext];
id userInfo = [RKTestFixture parsedObjectWithContentsOfFixture:@"DynamicKeys.json"];
RKObjectMapper* mapper = [RKObjectMapper mapperWithObject:userInfo mappingProvider:provider];
[mapper performMapping];