@Override
  public Object execute(VirtualFrame frame) {
    // TODO(cs): can module ever not evaluate to a RubyModule?

    final RubyModule moduleObject = (RubyModule) module.execute(frame);

    final Object rhsValue = rhs.execute(frame);

    assert rhsValue != null;
    assert !(rhsValue instanceof String);

    moduleObject.setModuleConstant(name, rhsValue);

    return rhsValue;
  }
Exemple #2
0
  public boolean isVisibleTo(Node currentNode, RubyClass callerClass) {
    switch (visibility) {
      case PUBLIC:
        return true;

      case PROTECTED:
        for (RubyModule ancestor : callerClass.ancestors()) {
          if (ancestor == declaringModule || ancestor.getMetaClass() == declaringModule) {
            return true;
          }
        }

        return false;

      case PRIVATE:
        // A private method may only be called with an implicit receiver,
        // in which case the visibility must not be checked.
        return false;

      default:
        return false;
    }
  }