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