How to change current layer by ruby API

hello …
i have make a plugin to make dealing with a lot of layers easier … and controlling of layer visibility works well but i didn’t found any API for change current layer , so i wondering how i can make that screenshot?

As @jiminybillybob indicated, try the “model.active_layer = layer” method.