# All files / decorators/gapi-scope gapi-scope.ts

100% Statements 15/15
100% Branches 0/0
100% Functions 3/3
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    212x
    2x

    2x
    1x

    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x

     import { ControllerContainerService } from '../../utils/services/controller-service/controller.service';
    import Container from '../../utils/container/index';
    import { GenericGapiResolversType } from '../../utils/services/controller-service/controller.service';

    export function Scope<T>(...arg: string[]): Function {
        const scope = {scope: arg};
        // TypedPropertyDescriptor<(id: T) => T>
        return (t: any, propKey: string, desc: TypedPropertyDescriptor<any>) => {
            const descriptor = desc;
            const originalMethod = descriptor.value;
            const propertyKey = propKey;
            const self = t;
            descriptor.value = function (...args: any[]) {
                const returnValue = originalMethod.apply(args);
                Object.assign(returnValue, scope);
                return returnValue;
            };
            Container.get(ControllerContainerService).createController(self.constructor.name).setDescriptor(propertyKey, descriptor);
            return descriptor;
        };
      }