1 31 package org.jruby; 32 33 import java.util.Map ; 34 35 47 public final class IncludedModuleWrapper extends RubyClass { 48 private RubyModule delegate; 49 50 public IncludedModuleWrapper(Ruby runtime, RubyClass superClass, RubyModule delegate) { 51 super(runtime, superClass, null); 52 54 this.delegate = delegate; 55 } 56 57 63 public IncludedModuleWrapper newIncludeClass(RubyClass superClass) { 64 IncludedModuleWrapper includedModule = new IncludedModuleWrapper(getRuntime(), superClass, getNonIncludedClass()); 65 66 if (getSuperClass() != null) { 68 includedModule.includeModule(getSuperClass()); 69 } 70 71 return includedModule; 72 } 73 74 public boolean isModule() { 75 return false; 76 } 77 78 public boolean isClass() { 79 return false; 80 } 81 82 public boolean isIncluded() { 83 return true; 84 } 85 86 public boolean isImmediate() { 87 return true; 88 } 89 90 public RubyClass getMetaClass() { 91 return delegate.getMetaClass(); 92 } 93 94 public void setMetaClass(RubyClass newRubyClass) { 95 throw new UnsupportedOperationException ("An included class is only a wrapper for a module"); 96 } 97 98 public Map getMethods() { 99 return delegate.getMethods(); 100 } 101 102 public void setMethods(Map newMethods) { 103 throw new UnsupportedOperationException ("An included class is only a wrapper for a module"); 104 } 105 106 public Map getInstanceVariables() { 107 return delegate.getInstanceVariables(); 108 } 109 110 public void setInstanceVariables(Map newMethods) { 111 throw new UnsupportedOperationException ("An included class is only a wrapper for a module"); 112 } 113 114 public String getName() { 115 return delegate.getName(); 116 } 117 118 public RubyModule getNonIncludedClass() { 119 return delegate; 120 } 121 122 public RubyClass getRealClass() { 123 return getSuperClass().getRealClass(); 124 } 125 126 public boolean isSame(RubyModule module) { 127 return delegate.isSame(module); 128 } 129 130 134 public RubyFixnum id() { 135 return delegate.id(); 136 } 137 } 138 | Popular Tags |