The concept of a Group or Component being “open for edit” or the “active context” comes purely from the GUI, where a user needs to access a Group or Component’s Entities to manipulate them. Are you trying to program something that will make a particular Group or Component active and then turn over control for the user to edit it via the GUI? Otherwise, as @TIG pointed out, your Ruby code can directly access the Entities collection of any Group or ComponentDefinition regardless of what is active in the GUI.