Fail to fully save an Object into game save

Hi, i created a simple function like this:
Code:
function Game_Emap() {
    this.initialize.apply(this, arguments);
}

Game_Emap.prototype.initialize = function() {
    this._origin = 0.5;
    this._hideEmap = false;
    this._x = 0;
    this._y = 0;
    this._opacity = 255;
    this._blendMode = 0;
    this._updateDelay =1;
};

Game_Emap.prototype.update = function() {
};

Game_Emap.prototype.getRotation = function(event) {
    var result = 0;
    switch(event._direction) {
        case 2:
            result = 180; break;
        case 4:
            result = 270; break;
        case 6:
            result = 90; break;
        case 8:
            result = 0; break;
        default:
            result = 0;
    }
    return result;
};

Then i tried to save it into Game's Save:
Code:
var $gameEmap = null;
var old1 = DataManager.createGameObjects;
DataManager.createGameObjects = function() {
    old1.call(this);
    $gameEmap = new Game_Emap();
};

var old2 = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
    var contents = old2.call(this);
    contents.eMap = $gameEmap;
    return contents;
};

var old3 = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
    old3.call(this, contents);
    $gameEmap = contents.eMap;
};

But, only the init property of the Game_Emap object had been saved, the function getRotation hadn't been saved at all. I can't figure why is that? Game_Map object still have its all function saved just fine?
That is strange. Because I did something like that and managed to save.
Perhaps did you are using the self-invoking function?
JavaScript:
(function(){
    // your plugin code
})();
Because maybe the var $gameMap it in the local scope.
Don't know very well, I'm still always learning the mv code xD

But I leave to you my code, and you can compare.

Spoiler: Eli code
JavaScript:
"use strict"

var Imported = Imported || {};
Imported.Eli_Book = true;

var Eli = Eli || {};
Eli.Book = Eli.Book || {};

Eli.Book.Parameters = PluginManager.parameters("Eli's_Book");
Eli.Book.Param = Eli.Book.Param || {};

function Game_Eli() {
    this.initialize.apply(this, arguments);
};

Game_Eli.prototype.initialize = function(){
    this.helpWindowsParameters();
    this.checkPointParameters();
};

Game_Eli.prototype.helpWindowsParameters = function(){};
Game_Eli.prototype.checkPointParameters = function(){};

var $gameEli = null;

Eli.Book.DataManager_createGameObjects = DataManager.createGameObjects;
DataManager.createGameObjects = function() {
    Eli.Book.DataManager_createGameObjects.call(this);
    $gameEli = new Game_Eli();
};

Eli.Book.DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
    let alias = Eli.Book.DataManager_makeSaveContents.call(this);
    alias.eli = $gameEli;
    return alias;
};

Eli.Book.DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
    Eli.Book.DataManager_extractSaveContents.call(this, contents);
    $gameEli = contents.eli;
};
@Eliaquim It's was really exactly as you said. Thank you 😀 I put it's inside self-invoke function and couldn't figure why until you told me

Original thread: https://forums.rpgmakerweb.com/threads/fail-to-fully-save-an-object-into-game-save.121090/