@@ -20,7 +20,8 @@ export class MiddlewareControl {
2020 * @private
2121 * A member holding map of MiddlewareOptions
2222 */
23- private middlewareOptions : Map < string , MiddlewareOptions > ;
23+ // tslint:disable-next-line:ban-types
24+ private middlewareOptions : Map < Function , MiddlewareOptions > ;
2425
2526 /**
2627 * @public
@@ -30,31 +31,38 @@ export class MiddlewareControl {
3031 * @returns The instance of MiddlewareControl
3132 */
3233 public constructor ( middlewareOptions : MiddlewareOptions [ ] = [ ] ) {
33- this . middlewareOptions = new Map < string , MiddlewareOptions > ( ) ;
34+ // tslint:disable-next-line:ban-types
35+ this . middlewareOptions = new Map < Function , MiddlewareOptions > ( ) ;
3436 for ( const option of middlewareOptions ) {
35- const name = option . constructor . name ;
36- this . middlewareOptions . set ( name , option ) ;
37+ const fn = option . constructor ;
38+ this . middlewareOptions . set ( fn , option ) ;
3739 }
3840 }
3941
4042 /**
4143 * @public
42- * To get the middleware option using the class name of the option
43- * @param {string } name - The class name of the strongly typed option class
44+ * To get the middleware option using the class of the option
45+ * @param {Function } fn - The class of the strongly typed option class
4446 * @returns The middleware option
47+ * @example
48+ * // if you wanted to return the middleware option associated with this class (MiddlewareControl)
49+ * // call this function like this:
50+ * getMiddlewareOptions(MiddlewareControl)
4551 */
46- public getMiddlewareOptions ( name : string ) : MiddlewareOptions {
47- return this . middlewareOptions . get ( name ) ;
52+ // tslint:disable-next-line:ban-types
53+ public getMiddlewareOptions ( fn : Function ) : MiddlewareOptions {
54+ return this . middlewareOptions . get ( fn ) ;
4855 }
4956
5057 /**
5158 * @public
52- * To set the middleware options using the class name of the option
53- * @param {string } name - The class name of the strongly typed option class
59+ * To set the middleware options using the class of the option
60+ * @param {Function } fn - The class of the strongly typed option class
5461 * @param {MiddlewareOptions } option - The strongly typed middleware option
5562 * @returns nothing
5663 */
57- public setMiddlewareOptions ( name : string , option : MiddlewareOptions ) : void {
58- this . middlewareOptions . set ( name , option ) ;
64+ // tslint:disable-next-line:ban-types
65+ public setMiddlewareOptions ( fn : Function , option : MiddlewareOptions ) : void {
66+ this . middlewareOptions . set ( fn , option ) ;
5967 }
6068}
0 commit comments