-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched to Zeitwerk as autoloader. (#27)
Signed-off-by: Hermann Mayer <hermann.mayer92@gmail.com>
- Loading branch information
Showing
4 changed files
with
54 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support' | ||
require 'active_support/concern' | ||
require 'active_support/configurable' | ||
require 'active_support/cache' | ||
require 'active_support/core_ext/hash' | ||
require 'active_support/time' | ||
require 'active_support/time_with_zone' | ||
require 'retries' | ||
require 'factory_bot' | ||
|
||
module FactoryBot | ||
# The top level namespace for the factory_bot_instrumentation gem. | ||
module Instrumentation | ||
# Setup a Zeitwerk autoloader instance and configure it | ||
loader = Zeitwerk::Loader.for_gem_extension(FactoryBot) | ||
|
||
# Finish the auto loader configuration | ||
loader.setup | ||
|
||
# Make sure to eager load all constants | ||
loader.eager_load | ||
|
||
class << self | ||
attr_writer :configuration | ||
|
||
# Retrieve the current configuration object. | ||
# | ||
# @return [Configuration] | ||
def configuration | ||
@configuration ||= Configuration.new | ||
end | ||
|
||
# Configure the concern by providing a block which takes | ||
# care of this task. Example: | ||
# | ||
# FactoryBot::Instrumentation.configure do |conf| | ||
# # conf.xyz = [..] | ||
# end | ||
def configure | ||
yield(configuration) | ||
end | ||
|
||
# Reset the current configuration with the default one. | ||
def reset_configuration! | ||
self.configuration = Configuration.new | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support' | ||
require 'active_support/concern' | ||
require 'active_support/configurable' | ||
require 'active_support/cache' | ||
require 'active_support/core_ext/hash' | ||
require 'active_support/time' | ||
require 'active_support/time_with_zone' | ||
require 'retries' | ||
|
||
require 'factory_bot' | ||
require 'factory_bot/instrumentation/configuration' | ||
require 'factory_bot/instrumentation/engine' | ||
|
||
module FactoryBot | ||
# The top level namespace for the factory_bot_instrumentation gem. | ||
module Instrumentation | ||
class << self | ||
attr_writer :configuration | ||
end | ||
|
||
# Retrieve the current configuration object. | ||
# | ||
# @return [Configuration] | ||
def self.configuration | ||
@configuration ||= Configuration.new | ||
end | ||
|
||
# Configure the concern by providing a block which takes | ||
# care of this task. Example: | ||
# | ||
# FactoryBot::Instrumentation.configure do |conf| | ||
# # conf.xyz = [..] | ||
# end | ||
def self.configure | ||
yield(configuration) | ||
end | ||
|
||
# Reset the current configuration with the default one. | ||
def self.reset_configuration! | ||
self.configuration = Configuration.new | ||
end | ||
end | ||
end | ||
require 'factory_bot/instrumentation' |