-
-
Save coop/e4e13b850fcf0440f711d7c5f78d2521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "set" | |
module Cobra | |
def self.paths | |
@paths ||= Set.new | |
end | |
def self.register(path) | |
paths << path | |
end | |
class Railtie < ::Rails::Railtie | |
config.cobra = ActiveSupport::OrderedOptions.new | |
config.cobra.pattern = ["*", "*.rb"] | |
config.cobra.directories = %w( | |
app/process_managers | |
app/read_models | |
) | |
config.to_prepare { Railtie.setup! } | |
def setup! | |
return if Rails.configuration.eager_load | |
Cobra.config.reset | |
paths = Cobra.paths.flat_map do |path| | |
config.cobra.directories.flat_map do |directory| | |
Dir[path.join(directory, *config.cobra.pattern)] | |
end | |
end | |
paths.each { |path| require_dependency(path) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment