Exception: ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Exceptions::InvalidEvaluateByValue

Inherits:
Exception
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/can_have_step_aware_enumerables/exceptions.rb

Instance Method Summary collapse

Methods inherited from Exception

new

Instance Method Details

#initialize_with_kwargs(value:) ⇒ void

This method returns an undefined value.

Parameters:

  • value (Object)

    Can be any type.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/exceptions.rb', line 65

def initialize_with_kwargs(value:)
  message = <<~TEXT
    `evaluate_by` value `#{value}` is NOT supported.

    Here are some examples of valid values:
      # `Symbol` value.
      .result(evaluate_by: :to_a)

      # `String` value.
      .result(evaluate_by: "to_h")

      # `Proc` value.
      .result(evaluate_by: ->(enumerable) { enumerable.to_set })

      # Object that respond to `call`.
      class Evaluator
        def self.call(enumerable)
          enumerable.join
        end
      end

      .result(evaluate_by: Evaluator)

      # Pass `nil` to skip evaluation (NOT recommended for enumerators).
      .result(evaluate_by: nil)
  TEXT

  initialize(message)
end