Skip to content

Commit ef819a7

Browse files
joerixaopolleolleolle
authored andcommitted
Make respond_to? work for all keys
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
1 parent bb68db9 commit ef819a7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/warbler/traits/war.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ class WebxmlOpenStruct < OpenStruct
176176

177177
def initialize(key = 'webxml')
178178
@key = key
179-
@table = Hash.new { |h, k| h[k] = WebxmlOpenStruct.new(k) }
179+
@table = Hash.new { |h, k|
180+
new_ostruct_member!(k)
181+
h[k] = WebxmlOpenStruct.new(k)
182+
}
180183

181184
@servlet_filter_async = nil # true/false
182185
end

0 commit comments

Comments
 (0)