Skip to content

Commit

Permalink
Make respond_to? work for all keys
Browse files Browse the repository at this point in the history
On JRuby 9.3 new_ostruct_member! checks if it already knows a new key by
checking the `@table` instance variable, before checking whether a
method is already defined (I assume because it's faster in the common
case), the way `@table` is handled with auto-vivifying values made this
not work properly for nested assignments.

E.g. `config.webxml.rails.env = 'production'` would auto-vivify
config.webxml.rails without defining a singleton method.

On JRuby 9.3 we could scrap method_missing, it has the right behaviour
(i.e. the workaround for #366 added in 9245f4c is no longer
required). Unfortunately it's still required on JRuby 9.2
  • Loading branch information
joerixaop authored and olleolleolle committed Aug 9, 2022
1 parent bb68db9 commit ef819a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/warbler/traits/war.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ class WebxmlOpenStruct < OpenStruct

def initialize(key = 'webxml')
@key = key
@table = Hash.new { |h, k| h[k] = WebxmlOpenStruct.new(k) }
@table = Hash.new { |h, k|
new_ostruct_member!(k)
h[k] = WebxmlOpenStruct.new(k)
}

@servlet_filter_async = nil # true/false
end
Expand Down

0 comments on commit ef819a7

Please sign in to comment.