public function set($keyword, $factory)
    {
        if (!(is_string($factory) || $factory instanceof \Closure)) {
            throw new \InvalidArgumentException(
                sprintf('Expected a string or Closure, got %s', gettype($keyword))
            );
        }

        $this->rules[$keyword] = function ($container) use ($factory) {
            static $object;

            if (is_null($object)) {
                $object = is_string($factory) ? new $factory() : $factory($container);
            }

            return $object;
        };
    }