File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,10 @@ def call_method?(method_name)
336
336
local_calls . any? { |local_call_method_name | parent . find_method_by_name ( local_call_method_name ) &.call_method? ( method_name ) }
337
337
end
338
338
339
+ def call_any_method? ( method_names )
340
+ method_names . any? { |method_name | call_method? ( method_name ) }
341
+ end
342
+
339
343
def to_h
340
344
{ name : @name }
341
345
end
Original file line number Diff line number Diff line change @@ -205,4 +205,36 @@ def send_notificaiton
205
205
expect ( method_definition . call_method? ( 'send_notification' ) ) . to be_truthy
206
206
expect ( method_definition . call_method? ( 'activate' ) ) . to be_falsey
207
207
end
208
+
209
+ it 'check if call any method' do
210
+ rewriter =
211
+ Synvert ::Rewriter . new 'test' , 'ruby_parse_helper' do
212
+ call_helper 'ruby/parse'
213
+ end
214
+
215
+ FileUtils . mkdir_p ( 'app/models' )
216
+ File . write ( 'app/models/user.rb' , <<~EOF )
217
+ class User < ApplicationRecord
218
+ def activate
219
+ update(:active: true)
220
+ send_notification
221
+ end
222
+
223
+ def deactivate
224
+ update(:active: false)
225
+ send_notification
226
+ end
227
+
228
+ def send_notificaiton
229
+ end
230
+ end
231
+ EOF
232
+
233
+ rewriter . process
234
+
235
+ definitions = rewriter . load_data ( :ruby_definitions )
236
+ class_definition = definitions . find_class_by_full_name ( 'User' )
237
+ method_definition = class_definition . find_method_by_name ( 'deactivate' )
238
+ expect ( method_definition . call_any_method? ( [ 'send_notification' , 'activate' ] ) ) . to be_truthy
239
+ end
208
240
end
You can’t perform that action at this time.
0 commit comments