我是
ruby on rails的新手,同时通过rails代码我找到了
attr_internal :response_body attr_internal :action_name attr_internal :formats
它是做什么的?为什么他们使用attr_internal为响应主体或动作名称分配行动?
解决方法
它声明了一个由内部命名的实例变量支持的属性读取器和编写器.
http://rubydoc.info/docs/rails/Module:attr_internal看看这个
查看主文件
def attr_internal_define(attr_name,type) internal_name = attr_internal_ivar_name(attr_name).sub(/\A@/,'') class_eval do # class_eval is necessary on 1.9 or else the methods a made private # use native attr_* methods as they are faster on some Ruby implementations send("attr_#{type}",internal_name) end attr_name,internal_name = "#{attr_name}=","#{internal_name}=" if type == :writer alias_method attr_name,internal_name remove_method internal_name end # use native attr_* methods as they are faster on some Ruby implementations send("attr_#{type}",internal_name)
这里的伎俩