Sha256: 0b349bc1ff91ef789e214c5626f8ad2c45fe88c87df0875afb48d85e38538930
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'rails-env/version' module RailsEnv class Railtie < Rails::Railtie initializer 'rails-env' do Rails.env.extend(Extension) end end def self.propagate_configuration! propagate(:action_mailer, '::ActionMailer::Base') propagate(:active_record, '::ActiveRecord::Base') propagate(:active_job, '::ActiveJob::Base') propagate(:time_zone, '::Time', :zone) propagate(:i18n, '::I18n') end def self.propagate(options_name, target_name, target_property = nil) return unless Object.const_defined?(target_name) return unless Rails.configuration.respond_to?(options_name) target = Object.const_get(target_name) options = Rails.configuration.public_send(options_name) if options.kind_of?(Enumerable) 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 module Extension def on(*envs, &block) env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym) Rails.application.configure(&block) if env_matched RailsEnv.propagate_configuration! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-env-1.0.1 | lib/rails-env.rb |