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

Fix missing new_ostruct_member in Ruby 2.7 #255

Merged
merged 11 commits into from
Jan 4, 2020
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rvm:
- 2.4.5
- 2.5.3
- 2.6.0
- 2.7.0
- truffleruby
gemfile:
- gemfiles/rails_4.2.gemfile
Expand All @@ -14,7 +15,10 @@ gemfile:
- gemfiles/sinatra.gemfile
matrix:
exclude:
# truffleruby does not seem to work with Rails
# Bundler 2.x coming with Ruby 2.7 does not work well with rails 4.2
- rvm: 2.7.0
gemfile: gemfiles/rails_4.2.gemfile
# TruffleRuby does not seem to work with Rails
- rvm: truffleruby
gemfile: gemfiles/rails_4.2.gemfile
- rvm: truffleruby
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Get rid of unused Rails Engine class definition ([#247](https://github.com/railsconfig/config/pull/247))
* Require dry-validation only when schema is specified ([#253](https://github.com/railsconfig/config/pull/253))

### Bug fixes

* Fix missing new_ostruct_member in Ruby 2.7 ([#255](https://github.com/railsconfig/config/pull/255))

### Changes

* Use sprockets 3.x when running unit tests for Rails 4.2 ([#256](https://github.com/railsconfig/config/pull/256))
Expand Down
3 changes: 1 addition & 2 deletions lib/config/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,14 @@ def __convert(h) #:nodoc:

h.each do |k, v|
k = k.to_s if !k.respond_to?(:to_sym) && k.respond_to?(:to_s)
s.new_ostruct_member(k)

if v.is_a?(Hash)
v = v["type"] == "hash" ? v["contents"] : __convert(v)
elsif v.is_a?(Array)
v = v.collect { |e| e.instance_of?(Hash) ? __convert(e) : e }
end

s.send("#{k}=".to_sym, v)
s[k] = v
end
s
end
Expand Down