Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/RemovePROViewModelEquality'
Browse files Browse the repository at this point in the history
  • Loading branch information
joshvera committed Apr 12, 2012
2 parents 39b3f29 + fbde1a9 commit c4c3f1c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 43 deletions.
3 changes: 0 additions & 3 deletions Proton/PROViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ typedef enum {
* subclasses, using the behavior of <encodingBehaviorForKey:> to determine
* which properties to archive.
*
* The implementations of `-hash` and `-isEqual:` are based on the `readwrite`
* properties of the class, including the <model> property.
*
* Upon deallocation, instances of this class will automatically invoke
* <[NSObject removeAllOwnedObservers]> and <[PROBinding
* removeAllBindingsFromOwner:>, and automatically unregister from any
Expand Down
35 changes: 0 additions & 35 deletions Proton/PROViewModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,39 +269,4 @@ - (NSString *)description {
return str;
}

- (NSUInteger)hash {
return [self.model hash];
}

- (BOOL)isEqual:(PROViewModel *)viewModel {
if (self == viewModel)
return YES;

if (![viewModel isMemberOfClass:self.class])
return NO;

if (!NSEqualObjects(self.model, viewModel.model))
return NO;

NSMutableArray *readwriteKeys = [NSMutableArray array];
[self.class enumeratePropertiesUsingBlock:^(objc_property_t property, NSString *key){
ext_propertyAttributes *attributes = ext_copyPropertyAttributes(property);
if (!PROAssert(attributes, @"Could not retrieve attributes for property \"%@\" on %@", key, self.class))
return;

@onExit {
free(attributes);
};

if (attributes->readonly)
return;

[readwriteKeys addObject:key];
}];

NSDictionary *selfValues = [self dictionaryWithValuesForKeys:readwriteKeys];
NSDictionary *otherValues = [viewModel dictionaryWithValuesForKeys:readwriteKeys];
return NSEqualObjects(selfValues, otherValues);
}

@end
7 changes: 2 additions & 5 deletions ProtonTests/PROViewModelTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ - (BOOL)validateSomeAction;
expect(viewModel.model).not.toBeNil();
});

it(@"is equal to same view model data", ^{
it(@"is not equal to same view model data", ^{
TestViewModel *otherViewModel = [[TestViewModel alloc] initWithModel:viewModel.model];
expect(viewModel).toEqual(otherViewModel);
expect(viewModel).not.toEqual(otherViewModel);
});

it(@"is not equal to a different view model", ^{
Expand Down Expand Up @@ -181,9 +181,6 @@ - (BOOL)validateSomeAction;
expect(decoded.unretainedObject).toEqual(unretainedObject);
expect(decoded.enabled).toBeTruthy();
expect(decoded.date).toEqual(viewModel.date);

decoded.model = viewModel.model;
expect(decoded).toEqual(viewModel);
});
});

Expand Down

0 comments on commit c4c3f1c

Please sign in to comment.