动态访问命名范围

如果我有3个命名范围,如

class Foo scope :test1, ... scope :test2, ... scope :test3, ... 

还有一个function

 def x(variable) end 

其中variable是一个字符串(“test1”,“test2”或“test3”)

如何通过知道变量的值来访问命名范围?

有点像Foo.variable

你会调用Foo.public_send(variable)