Module: Trailblazer::Test::Deprecation::Operation::Helper

Defined in:
lib/trailblazer/test/deprecation/operation/helper.rb

Instance Method Summary collapse

Instance Method Details

#call(operation_class, *args, &block) ⇒ Object



5
6
7
# File 'lib/trailblazer/test/deprecation/operation/helper.rb', line 5

def call(operation_class, *args, &block)
  call!(operation_class, args, &block)
end

#call!(operation_class, args, raise_on_failure: false) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/trailblazer/test/deprecation/operation/helper.rb', line 14

def call!(operation_class, args, raise_on_failure: false)
  operation_class.(*args).tap do |result|
    unless result.success?
      yield result if block_given?

      raise OperationFailedError, "factory(#{operation_class}) failed." if raise_on_failure
    end
  end
end

#factory(operation_class, *args, &block) ⇒ Object



9
10
11
# File 'lib/trailblazer/test/deprecation/operation/helper.rb', line 9

def factory(operation_class, *args, &block)
  call!(operation_class, args, raise_on_failure: true, &block)
end