Module: RailsEnv
- Defined in:
- lib/rails-env.rb,
lib/rails-env/version.rb
Defined Under Namespace
Modules: Extension
Classes: Railtie
Constant Summary
collapse
- VERSION =
"1.0.7"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
21
22
23
|
# File 'lib/rails-env.rb', line 21
def self.config
Rails.configuration
end
|
.propagate(options_name, target_name, target_property = nil) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/rails-env.rb', line 62
def self.propagate(options_name, target_name, target_property = nil)
return unless Object.const_defined?(target_name)
return unless config.respond_to?(options_name)
target = Object.const_get(target_name)
options = config.public_send(options_name)
if options.is_a?(Hash)
options.each do |key, value|
target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
end
else
target.public_send("#{target_property}=", options)
end
end
|
.propagate_autoload_paths ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rails-env.rb', line 51
def self.propagate_autoload_paths
all_autoload_paths = (
config.autoload_paths +
config.eager_load_paths +
config.autoload_once_paths
).uniq
ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
end
|
.propagate_cache_store ⇒ Object
37
38
39
|
# File 'lib/rails-env.rb', line 37
def self.propagate_cache_store
Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
end
|
.propagate_configuration! ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rails-env.rb', line 25
def self.propagate_configuration!
propagate(:action_controller, "::ActionController::Base")
propagate(:action_mailer, "::ActionMailer::Base")
propagate(:action_view, "::ActionView::Base")
propagate(:active_job, "::ActiveJob::Base")
propagate(:active_record, "::ActiveRecord::Base")
propagate(:time_zone, "::Time", :zone)
propagate_autoload_paths
propagate_i18n
propagate_cache_store
end
|
.propagate_i18n ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/rails-env.rb', line 41
def self.propagate_i18n
I18n.available_locales = (config.i18n.available_locales || [])
.compact
.map(&:to_sym)
.uniq
I18n.default_locale = config.i18n.default_locale if config.i18n.default_locale
I18n.locale = config.i18n.locale if config.i18n.locale
I18n.load_path += config.i18n.load_path if config.i18n.load_path
end
|