16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pakyow/behavior/verification.rb', line 16
def verify(values = nil, &block)
unless values
if self.class.__object_name_to_verify.nil?
raise "Expected values to be passed"
else
values = public_send(self.class.__object_name_to_verify)
end
end
original_values = values.deep_dup
result = Pakyow::Verifier.new(&block).call(values, context: self)
unless result.verified?
error = InvalidData.new_with_message(:verification)
error.context = { object: original_values, result: result }
raise error
end
end
|