Revise style

This commit is contained in:
Xavier Noria 2021-09-08 18:06:36 +02:00
parent 24956f2e5f
commit b9be4e1e31
2 changed files with 41 additions and 35 deletions

View File

@ -2,41 +2,43 @@
require "zeitwerk"
module Rails::Autoloaders # :nodoc:
require_relative "autoloaders/inflector"
module Rails
module Autoloaders # :nodoc:
require_relative "autoloaders/inflector"
class << self
include Enumerable
class << self
include Enumerable
def main
@main ||= Zeitwerk::Loader.new.tap do |loader|
loader.tag = "rails.main"
loader.inflector = Inflector
def main
@main ||= Zeitwerk::Loader.new.tap do |loader|
loader.tag = "rails.main"
loader.inflector = Inflector
end
end
end
def once
@once ||= Zeitwerk::Loader.new.tap do |loader|
loader.tag = "rails.once"
loader.inflector = Inflector
def once
@once ||= Zeitwerk::Loader.new.tap do |loader|
loader.tag = "rails.once"
loader.inflector = Inflector
end
end
end
def each
yield main
yield once
end
def each
yield main
yield once
end
def logger=(logger)
each { |loader| loader.logger = logger }
end
def logger=(logger)
each { |loader| loader.logger = logger }
end
def log!
each(&:log!)
end
def log!
each(&:log!)
end
def zeitwerk_enabled?
true
def zeitwerk_enabled?
true
end
end
end
end

View File

@ -2,16 +2,20 @@
require "active_support/inflector"
module Rails::Autoloaders::Inflector # :nodoc:
# Concurrent::Map is not needed. This is a private class, and overrides
# must be defined while the application boots.
@overrides = {}
module Rails
module Autoloaders
module Inflector # :nodoc:
# Concurrent::Map is not needed. This is a private class, and overrides
# must be defined while the application boots.
@overrides = {}
def self.camelize(basename, _abspath)
@overrides[basename] || basename.camelize
end
def self.camelize(basename, _abspath)
@overrides[basename] || basename.camelize
end
def self.inflect(overrides)
@overrides.merge!(overrides)
def self.inflect(overrides)
@overrides.merge!(overrides)
end
end
end
end