Method: FindMethodInPath#call

Defined in:
app/services/find_method_in_path.rb

#call(path_id) ⇒ Object

Have a “Exists?” method that checks to see if something exists If it doesn’t use an Insert class and define which section it should go into If it does, work out the differences(?) and update them



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/find_method_in_path.rb', line 14

def call(path_id)
  path = Path.find(path_id)
  code = File.readlines(path.path).join
  source = RuboCop::ProcessedSource.new(code, 2.7)

  path.events.call.each_with_object({}) do |event, methods|
    methods[event.method.to_sym] = ''

    node = FindMethod.call(
      type: :def,
      name: event.method.to_sym,
      source: source
    )

    next unless node.present?

    methods[event.method.to_sym] = DisplayMethod.call(node: node, code: code)
  end
end