【发布时间】:2017-03-31 08:47:53
【问题描述】:
我知道ActiveSupport::Concern 后面隐藏着一个依赖管理系统。我不完全理解它(我不确定我是否准备好了),但简而言之:是否可以将ActiveSupport::Concern 与香草(非ActiveSupport::Concern)模块混合使用,还是有陷阱?
这里有一些我能想到的不同用法的例子
module Vanilla
module ModuleIncludedInASC
# Vanilla module
end
module ModuleIncludedInClass
# Vanilla module
end
module ASC
module ConcernIncludedInClass
extend ActiveSupport::Concern
...
end
module ConcernIncludedInASC
extend ActiveSupport::Concern
...
end
module ConcernIncludingVanillaModulesIncludedInClass
extend ActiveSupport::Concern
include Vanilla::VanillaConcernIncludedInASC
end
module ConcernIncludingASCConcernIncludedInASC
extend ActiveSupport::Concern
include ConcernIncludedInASC
end
end
class MyFoo
include Vanilla::ModuleIncludedInClass
include ASC::ConcernIncludedInClass
include ASC::ConcernIncludingVanillaModulesIncludedInClass
end
# Ans also possibly, ActiveSupport::Concern modules included in vanilla modules...?
这可能会导致问题吗?
【问题讨论】:
标签: ruby ruby-on-rails-5 activesupport activesupport-concern