Skip to content

Commit

Permalink
[#38] rename isEqual and hash methods so as not to override the defau…
Browse files Browse the repository at this point in the history
…lts and to more accurately reflect what they do
  • Loading branch information
vickeryj committed Feb 9, 2009
1 parent 2a5f1d7 commit 34fff49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Classes/PersonTest.m
Expand Up @@ -36,7 +36,7 @@ -(void) testPersonCreate {
NSArray *people = [Person findAllRemote];

for(Person *person in people) {
if([toCreate isEqual:person]) {
if([toCreate isEqualToRemote:person]) {
found = YES;
}
}
Expand All @@ -50,7 +50,7 @@ -(void) testPersonUpdate {
STAssertTrue( [toUpdate saveRemote], @"Should have been true");
NSArray *people = [Person findAllRemote];
for(Person *person in people) {
if([toUpdate isEqual:person] && [toUpdate.name isEqualToString:person.name]) {
if([toUpdate isEqualToRemote:person] && [toUpdate.name isEqualToString:person.name]) {
found = YES;
}
}
Expand All @@ -60,7 +60,7 @@ -(void) testPersonUpdate {
-(void) testFindPerson {
NSArray * people = [Person findAllRemote];
Person *toFind = (Person *)[people objectAtIndex:0];
STAssertTrue([toFind isEqual:[Person findRemote:toFind.personId]], @"Should of returned %@",toFind.name);
STAssertTrue([toFind isEqualToRemote:[Person findRemote:toFind.personId]], @"Should of returned %@",toFind.name);
}


Expand Down
4 changes: 4 additions & 0 deletions Classes/lib/NSObject+ObjectiveResource.h
Expand Up @@ -72,4 +72,8 @@ typedef enum {
- (NSString *)getRemoteCollectionPath;
- (NSString *)convertToRemoteExpectedType;

//Equality test for remote enabled objects based on class name and remote id
- (BOOL)isEqualToRemote:(id)anObject;
- (NSUInteger)hashForRemote;

@end
4 changes: 2 additions & 2 deletions Classes/lib/NSObject+ObjectiveResource.m
Expand Up @@ -163,11 +163,11 @@ - (NSString *)convertToRemoteExpectedType {
}

#pragma mark default equals methods for id and class based equality
- (BOOL)isEqual:(id)anObject {
- (BOOL)isEqualToRemote:(id)anObject {
return [NSStringFromClass([self class]) isEqualToString:NSStringFromClass([anObject class])] &&
[anObject respondsToSelector:@selector(getRemoteId)] && [[anObject getRemoteId] isEqualToString:[self getRemoteId]];
}
- (NSUInteger)hash {
- (NSUInteger)hashForRemote {
return [[self getRemoteId] intValue] + [NSStringFromClass([self class]) hash];
}

Expand Down

0 comments on commit 34fff49

Please sign in to comment.