diff --git a/CHANGELOG.md b/CHANGELOG.md index 728bf7bd..328b63f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,14 @@ ## Next +### New features + * Allow to use custom filename && directory name to store configs ([#341](https://github.com/rubyconfig/config/pull/341)) +### Bug fixes + +* Prevent name collision with private methods from ancestors ([#351](https://github.com/rubyconfig/config/pull/351)) + ## 5.1.0 * Fix conflicts with Rails 7 active_support methods ([#347](https://github.com/rubyconfig/config/pull/347)) diff --git a/lib/config/options.rb b/lib/config/options.rb index 08f3d409..07944b73 100644 --- a/lib/config/options.rb +++ b/lib/config/options.rb @@ -122,7 +122,7 @@ def merge!(hash) def [](param) return super if SETTINGS_RESERVED_NAMES.include?(param) return super if RAILS_RESERVED_NAMES.include?(param) - send("#{param}") + public_send("#{param}") end def []=(param, value) diff --git a/spec/fixtures/reserved_keywords.yml b/spec/fixtures/reserved_keywords.yml index 134941b1..1346fe73 100644 --- a/spec/fixtures/reserved_keywords.yml +++ b/spec/fixtures/reserved_keywords.yml @@ -7,6 +7,8 @@ max: kumquat min: fig exit!: taro table: strawberry +lambda: proc +proc: lambda # Rails 7.* reserved keywords minimum: 10 diff --git a/spec/options_spec.rb b/spec/options_spec.rb index ff65cc61..fbf0b0ca 100644 --- a/spec/options_spec.rb +++ b/spec/options_spec.rb @@ -19,6 +19,8 @@ expect(config.min).to eq('fig') expect(config.exit!).to eq('taro') expect(config.table).to eq('strawberry') + expect(config.lambda).to eq('proc') + expect(config.proc).to eq('lambda') end it 'should allow to access them using [] operator' do @@ -30,6 +32,8 @@ expect(config['min']).to eq('fig') expect(config['exit!']).to eq('taro') expect(config['table']).to eq('strawberry') + expect(config['lambda']).to eq('proc') + expect(config['proc']).to eq('lambda') expect(config[:select]).to eq('apple') expect(config[:collect]).to eq('banana') @@ -39,6 +43,8 @@ expect(config[:min]).to eq('fig') expect(config[:exit!]).to eq('taro') expect(config[:table]).to eq('strawberry') + expect(config[:lambda]).to eq('proc') + expect(config[:proc]).to eq('lambda') end context 'when Settings file is using keywords reserved by Rails 7' do @@ -64,14 +70,19 @@ it 'should allow to access them via object member notation' do expect(config.select).to be_nil expect(config.table).to be_nil + expect(config.exit!).to be_nil end it 'should allow to access them using [] operator' do expect(config['select']).to be_nil expect(config['table']).to be_nil + expect(config['lambda']).to be_nil + expect(config['proc']).to be_nil + expect(config['exit!']).to be_nil expect(config[:select]).to be_nil expect(config[:table]).to be_nil + expect(config[:exit!]).to be_nil end end end