@@ -189,26 +189,34 @@ def clear_children!
189
189
# 3. Call the method on the helper object
190
190
# 4. Call super
191
191
#
192
- def method_missing ( name , *args , &block )
193
- if current_arbre_element . respond_to? ( name )
194
- current_arbre_element . send name , *args , &block
195
- elsif assigns && assigns . has_key? ( name )
196
- assigns [ name ]
197
- elsif helpers . respond_to? ( name )
198
- helper_capture ( name , *args , &block )
199
- else
200
- super
192
+ if Gem ::Version . new ( RUBY_VERSION ) >= Gem ::Version . new ( "2.7.a" )
193
+ def method_missing ( name , *args , **kwargs , &block )
194
+ if current_arbre_element . respond_to? ( name )
195
+ current_arbre_element . send name , *args , **kwargs , &block
196
+ elsif assigns && assigns . has_key? ( name )
197
+ assigns [ name ]
198
+ elsif helpers . respond_to? ( name )
199
+ s = ""
200
+ within ( Element . new ) { s = helpers . send ( name , *args , **kwargs , &block ) }
201
+ s . is_a? ( Element ) ? s . to_s : s
202
+ else
203
+ super
204
+ end
205
+ end
206
+ else
207
+ def method_missing ( name , *args , &block )
208
+ if current_arbre_element . respond_to? ( name )
209
+ current_arbre_element . send name , *args , &block
210
+ elsif assigns && assigns . has_key? ( name )
211
+ assigns [ name ]
212
+ elsif helpers . respond_to? ( name )
213
+ s = ""
214
+ within ( Element . new ) { s = helpers . send ( name , *args , &block ) }
215
+ s . is_a? ( Element ) ? s . to_s : s
216
+ else
217
+ super
218
+ end
201
219
end
202
- end
203
-
204
- # The helper might have a block that builds Arbre elements
205
- # which will be rendered (#to_s) inside ActionView::Base#capture.
206
- # We do not want such elements added to self, so we push a dummy
207
- # current_arbre_element.
208
- def helper_capture ( name , *args , &block )
209
- s = ""
210
- within ( Element . new ) { s = helpers . send ( name , *args , &block ) }
211
- s . is_a? ( Element ) ? s . to_s : s
212
220
end
213
221
214
222
def method_distance ( name )
0 commit comments