diff --git a/Files/WACDSCustomMapping.h b/Files/WACDSCustomMapping.h index 5574df0..dc4523b 100644 --- a/Files/WACDSCustomMapping.h +++ b/Files/WACDSCustomMapping.h @@ -32,6 +32,21 @@ typedef NSDate* _Nonnull (^WACDSMappingExpirationDateBuilder)(id _Nonnull object uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder; +/** + * Init the mapping + * + * @param objectEntityName The object entity name + * @param uniqueIdentifierPattern A pattern for unique identifier. Ex: booking_{#bookingID#} + * @param searchableItemAttributeSetBuilder A block which will be called for each object to index. You need to return an attribute set + * @param cleanValuesOnReplacement A bool which is used to change the default behaviour. By default is NO. + * + * @return a fresh mapping + */ +- (instancetype _Nonnull)initWithManagedObjectEntityName:(NSString *_Nonnull)objectEntityName + uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern + searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder + cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement; + /** * Get the unique identifier from an object based on the pattern * @@ -105,4 +120,4 @@ typedef NSDate* _Nonnull (^WACDSMappingExpirationDateBuilder)(id _Nonnull object uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder __deprecated_msg("Use `initWithManagedObjectEntityName: uniqueIdentifierPattern: searchableItemAttributeSetBuilder:` instead"); -@end \ No newline at end of file +@end diff --git a/Files/WACDSCustomMapping.m b/Files/WACDSCustomMapping.m index 80b516e..ccdb01a 100644 --- a/Files/WACDSCustomMapping.m +++ b/Files/WACDSCustomMapping.m @@ -26,6 +26,10 @@ @interface WACDSCustomMapping () @implementation WACDSCustomMapping - (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uniqueIdentifierPattern:(NSString *)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder)searchableItemAttributeSetBuilder { + return [self initWithManagedObjectEntityName:objectEntityName uniqueIdentifierPattern:uniqueIdentifierPattern searchableItemAttributeSetBuilder:searchableItemAttributeSetBuilder cleanValuesOnReplacement:NO]; +} + +- (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uniqueIdentifierPattern:(NSString *)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder)searchableItemAttributeSetBuilder cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement { WACDSClassAssertion(objectEntityName, NSString); WACDSClassAssertion(uniqueIdentifierPattern, NSString); @@ -37,7 +41,7 @@ - (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uni self->_searchableItemAttributeSetBuilder = searchableItemAttributeSetBuilder; // Create the pattern - self->_uniqueIdentifierStringPattern = [[WACDSStringPattern alloc] initWithPattern:uniqueIdentifierPattern cleanValuesOnReplacement:NO]; + self->_uniqueIdentifierStringPattern = [[WACDSStringPattern alloc] initWithPattern:uniqueIdentifierPattern cleanValuesOnReplacement:cleanValuesOnReplacement]; } return self; @@ -89,4 +93,4 @@ - (instancetype)initWithManagedObjectClass:(Class)objectClass uniqueIdentifierPa searchableItemAttributeSetBuilder:searchableItemAttributeSetBuilder]; } -@end \ No newline at end of file +@end