I\'m learning how to use class_eval in modules (I\'m somewhat familiar with class_eval) and came across this helpful class in resource_controller. In there they have things
Let's also note, that eval-ling strings should be avoided where possible. In your particular case, replacing #class_eval with #class_exec is possible, and should be preferred:
class_exec do
define_method block_accessor do |*args, &block|
unless args.empty? && block.nil?
args.push block if block_given?
instance_variable_set "@#{block_accessor}", [args].flatten
end
instance_variable_get "@#{block_accessor}"
end
end