def create(id, owner, reflection)
cache = owner[CachedItemProxy::CACHE_ATTRIBUTE]
cached_attributes = cache["#{reflection.klass.name}:#{id}"] if cache
cached_attributes ||= {}
cached_attributes["id"] = id
proxy = reflection.klass.instantiate(cached_attributes)
proxy.extend CachedItemProxy
proxy.instance_variable_set(:@owner, owner)
proxy.instance_variable_set(:@reflection, reflection)
proxy.reset
reflection.options[:cache].each do |attribute_name|
eval "def proxy.#{attribute_name}\n"+
" proxy_cache[\"#{attribute_name}\"] ||= super\n"+
"end"
end
proxy
end