lib/config_default/init.rb in config_default-0.2.5 vs lib/config_default/init.rb in config_default-0.3.0
- old
+ new
@@ -1,12 +1,29 @@
# frozen_string_literal: true
+module ConfigDefault::RailsApplicationConfigurationPatch
+ def load_database_yaml
+ ConfigDefault.load(:database, key: nil)
+ end
+
+ def database_configuration
+ load_database_yaml
+ end
+end
+
+module ConfigDefault::RailsApplicationPatch
+ def config_for(name, env: Rails.env)
+ data = ConfigDefault.load(name, key: env, deep_symbolize_keys: true)
+ ActiveSupport::OrderedOptions.new.merge(data)
+ end
+end
+
module ConfigDefault::Init
extend self
- def init_rails_monkey_patch!
+ def init_rails_patch!
return unless Object.const_defined?(:Rails)
- Rails::Application.prepend(ConfigDefault::RailsApplicationExtension)
- Rails::Application::Configuration.prepend(ConfigDefault::RailsApplicationConfigurationExtension)
+ Rails::Application.prepend(ConfigDefault::RailsApplicationPatch)
+ Rails::Application::Configuration.prepend(ConfigDefault::RailsApplicationConfigurationPatch)
end
end