Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define the constant on Object instead of Kernel #227

Merged
merged 10 commits into from
Jun 20, 2019
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Changes

* Upgraded dry-validation dependency to dry-schema 1.0 ([#224](https://github.com/railsconfig/config/pull/224))
* Moved constant to be defined on `Object` instead of `Kernel` ([#227](https://github.com/railsconfig/config/issues/227))

## 1.7.2

Expand Down
7 changes: 4 additions & 3 deletions lib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def self.load_files(*files)

# Loads and sets the settings constant!
def self.load_and_set_settings(*files)
Kernel.send(:remove_const, Config.const_name) if Kernel.const_defined?(Config.const_name)
Kernel.const_set(Config.const_name, Config.load_files(files))
name = Config.const_name
Object.send(:remove_const, name) if Object.const_defined?(name)
Object.const_set(name, Config.load_files(files))
end

def self.setting_files(config_root, env)
Expand All @@ -70,7 +71,7 @@ def self.setting_files(config_root, env)
end

def self.reload!
Kernel.const_get(Config.const_name).reload!
Object.const_get(Config.const_name).reload!
end
end

Expand Down