46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/hash_engine/transform.rb', line 46
def default_or_suppress(value, field_name, field_hash, instructions, result)
if (nil_check(instructions, value) || blank_check(instructions, value)) &&
required_check(field_hash) then
add_error(result[:error], "required field '#{field_name}' missing", field_name)
result[field_name] = instructions['default_value']
else
unless suppress_nil(instructions, value) || suppress_blank(instructions, value)
result[field_name] = value
end
end
end
|