Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/JSObjectionInjector.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

@interface JSObjectionInjector : NSObject

- (instancetype)initWithContext:(NSDictionary *)theGlobalContext;
- (instancetype)initWithContext:(NSDictionary *)theGlobalContext andModule:(JSObjectionModule *)theModule;
- (instancetype)initWithContext:(NSDictionary *)theGlobalContext andModules:(NSArray *)theModules;
- (instancetype)initWithContext:(NSMutableDictionary *)theGlobalContext;
- (instancetype)initWithContext:(NSMutableDictionary *)theGlobalContext andModule:(JSObjectionModule *)theModule;
- (instancetype)initWithContext:(NSMutableDictionary *)theGlobalContext andModules:(NSArray *)theModules;
- (id)getObject:(id)classOrProtocol;
- (id)getObject:(id)classOrProtocol named:(NSString*)name;
- (id)getObjectWithArgs:(id)classOrProtocol, ... NS_REQUIRES_NIL_TERMINATION;
Expand Down
9 changes: 5 additions & 4 deletions Source/JSObjectionInjector.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (void)configure {
@end

@interface JSObjectionInjector() {
NSDictionary *_globalContext;
NSMutableDictionary *_globalContext;
NSMutableDictionary *_context;
NSSet *_eagerSingletons;
NSMutableArray *_modules;
Expand All @@ -43,7 +43,7 @@ - (void)configureModule:(JSObjectionModule *)module;

@implementation JSObjectionInjector

- (instancetype)initWithContext:(NSDictionary *)theGlobalContext {
- (instancetype)initWithContext:(NSMutableDictionary *)theGlobalContext {
if ((self = [super init])) {
_globalContext = theGlobalContext;
_context = [[NSMutableDictionary alloc] init];
Expand All @@ -55,15 +55,15 @@ - (instancetype)initWithContext:(NSDictionary *)theGlobalContext {
return self;
}

- (instancetype)initWithContext:(NSDictionary *)theGlobalContext andModule:(JSObjectionModule *)theModule {
- (instancetype)initWithContext:(NSMutableDictionary *)theGlobalContext andModule:(JSObjectionModule *)theModule {
if ((self = [self initWithContext:theGlobalContext])) {
[self configureModule:theModule];
[self initializeEagerSingletons];
}
return self;
}

- (instancetype)initWithContext:(NSDictionary *)theGlobalContext andModules:(NSArray *)theModules {
- (instancetype)initWithContext:(NSMutableDictionary *)theGlobalContext andModules:(NSArray *)theModules {
if ((self = [self initWithContext:theGlobalContext])) {
for (JSObjectionModule *module in theModules) {
[self configureModule:module];
Expand Down Expand Up @@ -261,6 +261,7 @@ - (void)configureModule:(JSObjectionModule *)module {
NSSet *mergedSet = [module.eagerSingletons setByAddingObjectsFromSet:_eagerSingletons];
_eagerSingletons = mergedSet;
[_context addEntriesFromDictionary:module.bindings];
[_globalContext addEntriesFromDictionary:_context];
}

- (void)configureDefaultModule {
Expand Down