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有太多的方法可以作爲代理有用。
解決方案是什麼?