1 29 package org.jruby.internal.runtime; 30 31 import org.jruby.runtime.IAccessor; 32 import org.jruby.runtime.builtin.IRubyObject; 33 34 38 public class ReadonlyAccessor implements IAccessor { 39 private String name; 40 private IAccessor accessor; 41 42 public ReadonlyAccessor(String name, IAccessor accessor) { 43 assert name != null; 44 assert accessor != null; 45 46 this.name = name; 47 this.accessor = accessor; 48 } 49 50 public IRubyObject getValue() { 51 return accessor.getValue(); 52 } 53 54 public IRubyObject setValue(IRubyObject newValue) { 55 assert newValue != null; 56 57 throw newValue.getRuntime().newNameError(name + " is a read-only variable", name); 58 } 59 } 60 | Popular Tags |