Skip to content

Commit

Permalink
Applied coderabbit suggestion for throwIfFrozen method.
Browse files Browse the repository at this point in the history
  • Loading branch information
maratal committed Sep 12, 2024
1 parent bfaaba1 commit e22ff7c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 50 deletions.
9 changes: 9 additions & 0 deletions Source/ARTBaseQuery.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#import "ARTBaseQuery.h"

@implementation ARTBaseQuery

- (void)throwIfFrozen {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
}

@end
30 changes: 5 additions & 25 deletions Source/ARTDataQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ - (NSDate *)start {
}

- (void)setStart:(NSDate *)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_start = value;
}

Expand All @@ -61,11 +57,7 @@ - (NSDate *)end {
}

- (void)setEnd:(NSDate *)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_end = value;
}

Expand All @@ -74,11 +66,7 @@ - (uint16_t)limit {
}

- (void)setLimit:(uint16_t)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_limit = value;
}

Expand All @@ -87,11 +75,7 @@ - (ARTQueryDirection)direction {
}

- (void)setDirection:(ARTQueryDirection)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_direction = value;
}

Expand Down Expand Up @@ -122,11 +106,7 @@ - (BOOL)untilAttach {
}

- (void)setUntilAttach:(BOOL)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_untilAttach = value;
}

Expand Down
6 changes: 1 addition & 5 deletions Source/ARTRealtimePresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ - (BOOL)waitForSync {
}

- (void)setWaitForSync:(BOOL)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_waitForSync = value;
}

Expand Down
18 changes: 3 additions & 15 deletions Source/ARTRestPresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ - (NSUInteger)limit {
}

- (void)setLimit:(NSUInteger)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_limit = value;
}

Expand All @@ -71,11 +67,7 @@ - (NSString *)clientId {
}

- (void)setClientId:(NSString *)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_clientId = value;
}

Expand All @@ -84,11 +76,7 @@ - (NSString *)connectionId {
}

- (void)setConnectionId:(NSString *)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_connectionId = value;
}

Expand Down
6 changes: 1 addition & 5 deletions Source/ARTStats.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ - (ARTStatsGranularity)unit {
}

- (void)setUnit:(ARTStatsGranularity)value {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
[self throwIfFrozen];
_unit = value;
}

Expand Down
2 changes: 2 additions & 0 deletions Source/include/Ably/ARTBaseQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

@property (nonatomic, getter=isFrozen) BOOL frozen;

- (void)throwIfFrozen;

@end

0 comments on commit e22ff7c

Please sign in to comment.