aetherknight / recursive-open-struct

OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs
Other
276 stars 54 forks source link

Not working with Ruby 2.3.0 #41

Closed dglancy closed 8 years ago

dglancy commented 8 years ago

I'm getting the following when using Ruby 2.3.0:

2.3.0 :001 > ros = RecursiveOpenStruct.new( { fooa: { foob: 'fooc' } } )
 => #<RecursiveOpenStruct fooa={:foob=>"fooc"}> 
2.3.0 :002 > ros.fooa
 => {:foob=>"fooc"} 
2.3.0 :003 > ros.fooa.foob
NoMethodError: undefined method `foob' for {:foob=>"fooc"}:Hash
        from (irb):3
        from /Users/dglancy/.rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
        from /Users/dglancy/.rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
        from /Users/dglancy/.rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
        from /Users/dglancy/.rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /Users/dglancy/.rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:8:in `require'
        from bin/rails:8:in `<main>'
aetherknight commented 8 years ago

What version of Recursive-open-struct are you using?

aetherknight commented 8 years ago

I suspect that you are using a 0.x.x version of recursive-open-struct because I am unable to reproduce this with Ruby 2.3.0 and recursive-open-struct 1.0.0. Version 1.0.0 fixed some changes to OpenStruct in Ruby 2.3 that broke recursive-open-struct, and the behavior shown above mirrors the problem that recusrive-open-struct 0.6.5 had with Ruby 2.3.0.

If you upgrade, take a look at the changelog to make sure you are not relying on any of the API-breaking changes.