lib/rails-env.rb in rails-env-2.0.1 vs lib/rails-env.rb in rails-env-2.0.2
- old
+ new
@@ -13,10 +13,14 @@
end
end
end
module RailsEnv
+ def self.deprecations
+ @deprecations ||= []
+ end
+
class Railtie < Rails::Railtie
initializer "rails-env" do
Rails.env.extend(Extension)
end
end
@@ -28,11 +32,19 @@
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")
+
+ with_rails_constraint("< 7.0.0") do
+ propagate(:active_record, "::ActiveRecord::Base")
+ end
+
+ with_rails_constraint(">= 7.0.0") do
+ propagate(:active_record, "::ActiveRecord")
+ end
+
propagate(:time_zone, "::Time", :zone)
propagate_hosts
propagate_autoload_paths
propagate_i18n
propagate_cache_store
@@ -99,12 +111,12 @@
target.public_send("#{target_property}=", options)
end
end
def self.with_rails_constraint(constraint)
- Gem::Requirement
- .create(constraint)
- .satisfied_by?(Gem::Version.create(Rails::VERSION::STRING))
+ yield if Gem::Requirement
+ .create(constraint)
+ .satisfied_by?(Gem::Version.create(Rails::VERSION::STRING))
end
module Extension
def on(*envs, &block)
env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym)