【发布时间】:2017-01-13 02:49:40
【问题描述】:
我有两个不同版本的应用程序,它们使用的某些方法版本略有不同。
module Sinatra
class MyApp < Sinatra::Base
helpers Sinatra::Version1
helpers Sinatra::Version2
end
end
module Sinatra
module Version1
def say_hello
puts "Hello from Version1"
end
end
helpers Version1
end
module Sinatra
module Version2
def say_hello
puts "Hello from Version2"
end
end
helpers Version2
end
我意识到以这种方式指定的助手是“顶级”并且可用于所有路由。
我想为不同的路线提供不同版本的方法。有没有办法在模块化应用程序中实现这一点?
【问题讨论】: