Module: Solid::Process::Caller

Defined in:
lib/solid/process/caller.rb

Instance Method Summary collapse

Instance Method Details

#call(arg = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/solid/process/caller.rb', line 6

def call(arg = nil)
  output_already_set! if output?

  self.input = arg

  run_callbacks(:call) do
    ::Solid::Result.event_logs(name: self.class.name) do
      self.output =
        if dependencies&.invalid?
          Failure(:invalid_dependencies, dependencies: dependencies)
        elsif input.invalid?
          Failure(:invalid_input, input: input)
        else
          super(input.attributes.deep_symbolize_keys)
        end
    rescue ::Exception => exception
      rescue_with_handler(exception) || raise

      output
    end
  end

  run_callbacks(:success) if output.success?
  run_callbacks(:failure) if output.failure?

  output
end