1
如何通过发送将动态生成的方法的参数传递给我?Ruby语法通过发送动态生成的方法接受参数
下面我生成了几种方法,我希望他们接受“行”参数。
下面的代码生成方法,但我不知道如何让方法接受“行”参数。
@sql_columns.each do |attr|
(class << self; self end).send :define_method, attr do
key = @column_mapping[attr].to_s
row[key]
end
end
可能重复http://stackoverflow.com/questions/89650/how-do-you-pass-arguments-to-define-method ) –