diff --git a/Source/Factory/Assembly/TyphoonAssembly.m b/Source/Factory/Assembly/TyphoonAssembly.m index 01fc17c79..f540709b4 100644 --- a/Source/Factory/Assembly/TyphoonAssembly.m +++ b/Source/Factory/Assembly/TyphoonAssembly.m @@ -210,6 +210,16 @@ - (void)makeDefault [_factory makeDefault]; } +- (void)attachPostProcessor:(id)postProcessor +{ + if (!_factory) { + [NSException raise:NSInternalInconsistencyException + format:@"attachPostProcessor: requires the assembly to be activated."]; + } + [_factory attachPostProcessor:postProcessor]; +} + + //------------------------------------------------------------------------------------------- #pragma mark - Interface Methods diff --git a/Source/Factory/TyphoonComponentFactory.h b/Source/Factory/TyphoonComponentFactory.h index 488493fa1..05c2fdc12 100644 --- a/Source/Factory/TyphoonComponentFactory.h +++ b/Source/Factory/TyphoonComponentFactory.h @@ -73,6 +73,12 @@ - (void)makeDefault; +/** +Attach a TyphoonComponentFactoryPostProcessor to this component factory. +@param postProcessor The post-processor to attach. +*/ +- (void)attachPostProcessor:(id )postProcessor; + @end /** @@ -160,11 +166,5 @@ - (void)enumerateDefinitions:(void(^)(TyphoonDefinition *definition, NSUInteger index, TyphoonDefinition **definitionToReplace, BOOL *stop))block; -/** - Attach a TyphoonComponentFactoryPostProcessor to this component factory. - @param postProcessor The post-processor to attach. - */ -- (void)attachPostProcessor:(id )postProcessor; - @end diff --git a/Tests/Factory/Assembly/TyphoonAssemblyTests.m b/Tests/Factory/Assembly/TyphoonAssemblyTests.m index b8a2595a0..fda12c44d 100644 --- a/Tests/Factory/Assembly/TyphoonAssemblyTests.m +++ b/Tests/Factory/Assembly/TyphoonAssemblyTests.m @@ -41,7 +41,7 @@ - (void)test_activated_assembly_returns_activated_collaborators XCTAssertTrue([quest conformsToProtocol:@protocol(Quest)]); } -- (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonComponentFactory_componentForType +- (void)test_before_activation_raises_exception_when_invoking_TyphoonComponentFactory_componentForType { @try { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; @@ -53,7 +53,7 @@ - (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonCompon } } -- (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonComponentFactory_allComponentsForType +- (void)test_before_activation_raises_exception_when_invoking_TyphoonComponentFactory_allComponentsForType { @try { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; @@ -65,7 +65,7 @@ - (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonCompon } } -- (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonComponentFactory_componentForKey +- (void)test_before_activation_raises_exception_when_invoking_TyphoonComponentFactory_componentForKey { @try { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; @@ -77,7 +77,7 @@ - (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonCompon } } -- (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonComponentFactory_inject +- (void)test_before_activation_raises_exception_when_invoking_TyphoonComponentFactory_inject { @try { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; @@ -89,7 +89,7 @@ - (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonCompon } } -- (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonComponentFactory_inject_withSelector +- (void)test_before_activation_raises_exception_when_invoking_TyphoonComponentFactory_inject_withSelector { @try { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; @@ -101,7 +101,7 @@ - (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonCompon } } -- (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonComponentFactory_makeDefault +- (void)test_before_activation_raises_exception_when_invoking_TyphoonComponentFactory_makeDefault { @try { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; @@ -113,6 +113,18 @@ - (void)test_non_activated_assembly_raises_exception_when_invoking_TyphoonCompon } } +- (void)test_before_activation_raises_exception_when_invoking_attachPostProcessor +{ + @try { + MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; + [assembly attachPostProcessor:nil]; + XCTFail(@"Should have thrown exception"); + } + @catch (NSException *e) { + XCTAssertEqualObjects(@"attachPostProcessor: requires the assembly to be activated.", [e description]); + } +} + - (void)test_after_activation_TyphoonComponentFactory_methods_are_available { MiddleAgesAssembly *assembly = [MiddleAgesAssembly assembly]; diff --git a/Typhoon.podspec b/Typhoon.podspec index dbbd0fd31..f85d51518 100644 --- a/Typhoon.podspec +++ b/Typhoon.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'Typhoon' - spec.version = '3.0.3' + spec.version = '3.1.0' spec.license = 'Apache2.0' spec.summary = 'Dependency injection for Objective-C and Swift. Light-weight, yet flexible and full-featured.' spec.homepage = 'http://www.typhoonframework.org'