const container = pleasureDi({
Gateway (gatewayName) {
// holds the logic that resolves given gatewayName
// returns a function that will come with the container
return (/* container */) => {
return {
methodA (caller) {
return `methodA from ${gatewayName} called by ${caller}`
},
methodB (caller) {
return `methodB from ${gatewayName} called by ${caller}`
}
}
}
},
Service (serviceName) {
// holds the logic that resolves given serviceName
// returns a function that will come with the container
return ({ FreakingGateway }) => {
return {
methodC () {
return FreakingGateway.methodA(serviceName)
},
methodD () {
return FreakingGateway.methodB(serviceName)
}
}
}
}
})
const { PaymentService } = container
t.is(PaymentService.methodC(), 'methodA from FreakingGateway called by PaymentService')
t.is(PaymentService.methodD(), 'methodB from FreakingGateway called by PaymentService')
provides an interface to customize the container resolution