Module: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasNegatedResult::Concern

Includes:
ConvenientService::Support::Concern
Defined in:
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb

Instance Method Summary collapse

Instance Method Details

#negated?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb', line 18

def negated?
  Utils.to_bool(extra_kwargs[:negated])
end

#negated_resultConvenientService::Service::Plugins::HasJSendResult::Entities::Result



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb', line 35

def negated_result
  case status.to_sym
  when :success
    copy(
      overrides: {
        kwargs: {
          status: :failure,
          data: unsafe_data,
          message: "Original `result` is `success`#{" with `message` - #{unsafe_message}" unless unsafe_message.empty?}",
          code: "negated_#{unsafe_code}"
        }
      }
    )
  when :failure
    copy(
      overrides: {
        kwargs: {
          status: :success,
          data: unsafe_data,
          message: "Original `result` is `failure`#{" with `message` - #{unsafe_message}" unless unsafe_message.empty?}",
          code: "negated_#{unsafe_code}"
        }
      }
    )
  when :error
    copy
  end
end