1
14
15 package com.liferay.portal.scripting.ruby;
16
17 import org.jruby.Ruby;
18 import org.jruby.javasupport.Java;
19 import org.jruby.javasupport.JavaObject;
20 import org.jruby.javasupport.JavaUtil;
21 import org.jruby.runtime.IAccessor;
22 import org.jruby.runtime.builtin.IRubyObject;
23
24
29 class BeanGlobalVariable implements IAccessor {
30
31 public BeanGlobalVariable(Ruby ruby, Object bean, Class<?> type) {
32 _ruby = ruby;
33 _type = type;
34
35 _bean = JavaUtil.convertJavaToRuby(_ruby, bean, _type);
36
37 if (_bean instanceof JavaObject) {
38 _bean = Java.wrap(_ruby, _bean);
39 }
40 }
41
42 public IRubyObject getValue() {
43 return _bean;
44 }
45
46 public IRubyObject setValue(IRubyObject bean) {
47 _bean = bean;
48
49 return bean;
50 }
51
52 private IRubyObject _bean;
53 private Ruby _ruby;
54 private Class<?> _type;
55
56 }