0
如果可以的话,如何调用或重建SomePluggin
类直接在包含模块中调用get_content
方法,以减少模块中多余的get_content
模块?我可以直接调用像包含模块中的实例方法吗?
module Cms
class SomePluggin
def get_content
puts "please call me directly"
end
end
module Pluggin
extend ActiveSupport::Concern
included do
after_initialize :pluggin
end
attr_writer :pluggin
def pluggin
@pluggin ||= SomePluggin.new
end
def get_content # Is there any possibility to do this directly?
pluggin.get_content
end
end
end
最好的,谢谢! – luzny