__author__ = 'RemiZOffAlex'
__email__ = 'remizoffalex@mail.ru'

class Wrapper:
    def __init__(self, context, name):
        self.__context = context
        self.__name = name

    def __call__(self, *args, **kwargs):
        self.__function = self.__context.deferred(self.__name)
        print(self.__function, args, kwargs)
        response = self.__function(
            # self.__context,
            *args,
            **kwargs
        )
        return response


class Mutation:
    def __init__(self):
        self.__methods = {}

    def __call__(self, name):
        function = Wrapper(self, name)
        return function

    def register(self, name, function):
        self.__methods[name] = function

    def __getitem__(self, name):
        return self.__methods[name]

    def __setitem__(self, name, function):
        self.__methods[name] = function
