Ruby syntax accept arguments on dynamically generated methods via send
How I can pass arguments on dynamically generated methods via send ?
Below I generate on the fly several methods, I want th开发者_开发百科ey accept the "row" argument.
The code below generates the methods, but I don't know how let the methods accept the "row" argument.
@sql_columns.each do |attr|
(class << self; self end).send :define_method, attr do
key = @column_mapping[attr].to_s
row[key]
end
end
(class << self; self end).send :define_method, attr do |row|
精彩评论