0
课程代理知道远程系统上课程的ID,并在访问该课程时获取该信息。 示例代码:Rails:使远程代理保持活动记录
class Course < BasicObject
attr_accessor :course_id, :course_info
[..]
def method_missing(*a, &b)
if course_info.nil?
load_course_info
end
course_info.send(*a, &b)
end
[...]
def load_course_info
# this will fetch the course information from a remote server
# using the course_id
end
我的问题:我想用活动记录,使代理的COURSE_ID 坚持(而不是课程信息),从而使代理记得如何在稍后阶段再次获得信息。
课程从BasicObject继承,所以我不能做
Course < ActiveRecord::Base
我猜的ActiveRecord :: Base有太多的方法可以作为代理有用。
解决方案是什么?