Module: ServiceActor::Defaultable::PrependedMethods

Defined in:
lib/service_actor/defaultable.rb

Instance Method Summary collapse

Instance Method Details

#_callObject

rubocop:disable Metrics/MethodLength



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/service_actor/defaultable.rb', line 36

def _call # rubocop:disable Metrics/MethodLength
  self.class.inputs.each do |key, input|
    next if result.key?(key)

    unless input.key?(:default)
      raise_error_with(
        "The \"#{key}\" input on \"#{self.class}\" is missing",
      )
    end

    default = input[:default]

    if default.is_a?(Hash) && default[:is]
      default_for_advanced_mode_with(result, key, default)
    else
      default_for_normal_mode_with(result, key, default)
    end
  end

  self.class.outputs.each do |key, options|
    unless result.key?(key)
      result.send(:"#{key}=", options[:default])
    end
  end

  super
end