コード例 #1
0
ファイル: RubyMethod.java プロジェクト: byteit101/jruby
  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;
    }
  }