Module: CopyTunerClient::Rails
- Defined in:
- lib/copy_tuner_client/rails.rb
Overview
Responsible for Rails initialization
Class Method Summary collapse
- .controller_of_rails_engine?(controller) ⇒ Boolean
- .engine_namespaces ⇒ Object
-
.initialize ⇒ Object
Sets up the logger, environment, name, project root, and framework name for Rails applications.
Class Method Details
.controller_of_rails_engine?(controller) ⇒ Boolean
21 22 23 24 |
# File 'lib/copy_tuner_client/rails.rb', line 21 def self.controller_of_rails_engine?(controller) # SEE: https://github.com/rails/rails/blob/539144d2d61770dab66c8643e744441e52538e09/activesupport/lib/active_support/core_ext/module/introspection.rb#L39-L63 engine_namespaces.include?(controller.class.module_parents[-2]) end |
.engine_namespaces ⇒ Object
26 27 28 |
# File 'lib/copy_tuner_client/rails.rb', line 26 def self.engine_namespaces @engine_namespaces ||= ::Rails::Engine.subclasses.filter_map { _1.instance.railtie_namespace } end |
.initialize ⇒ Object
Sets up the logger, environment, name, project root, and framework name for Rails applications. Must be called after framework initialization.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/copy_tuner_client/rails.rb', line 6 def self.initialize CopyTunerClient.configure(false) do |config| config.environment_name = ::Rails.env config.logger = if defined?(::Rails::Console) Logger.new('/dev/null') elsif defined?(::Rails) && ::Rails.env.development? Logger.new('log/copy_tuner.log') else ::Rails.logger end config.framework = "Rails: #{::Rails::VERSION::STRING}" config.middleware = ::Rails.configuration.middleware end end |