@@ -137,6 +137,21 @@ def new(*args)
137
137
JS . global [ :Reflect ] . construct ( self , args . to_js )
138
138
end
139
139
140
+ # Provide a shorthand form for JS::Object#call
141
+ #
142
+ # This method basically calls the JavaScript method with the same
143
+ # name as the Ruby method name as is using JS::Object#call.
144
+ #
145
+ # Exceptions are the following cases:
146
+ # * If the method name ends with a question mark (?), the question mark is removed
147
+ # and the method is called as a predicate method. The return value is converted to
148
+ # a Ruby boolean value automatically.
149
+ #
150
+ # This shorthand is unavailable for the following cases and you need to use
151
+ # JS::Object#call instead:
152
+ # * If the method name is invalid as a Ruby method name (e.g. contains a hyphen, reserved word, etc.)
153
+ # * If the method name is already defined as a Ruby method under JS::Object
154
+ # * If the JavaScript method name ends with a question mark (?)
140
155
def method_missing ( sym , *args , &block )
141
156
sym_str = sym . to_s
142
157
if sym_str . end_with? ( "?" )
@@ -150,6 +165,9 @@ def method_missing(sym, *args, &block)
150
165
end
151
166
end
152
167
168
+ # Check if a JavaScript method exists
169
+ #
170
+ # See JS::Object#method_missing for details.
153
171
def respond_to_missing? ( sym , include_private )
154
172
return true if super
155
173
sym_str = sym . to_s
0 commit comments