| Conditions | 2 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # frozen_string_literal: true |
||
| 31 | def denormalize(value, _context, target_type) |
||
| 32 | return value if value.is_a?(target_type.type) |
||
| 33 | methods = MAPPING[downgrade_klass(target_type.type)] |
||
| 34 | methods.each do |method| |
||
| 35 | next unless value.respond_to?(method) |
||
| 36 | begin |
||
| 37 | result = value.send(method) |
||
| 38 | rescue ArgumentError |
||
| 39 | next |
||
| 40 | end |
||
| 41 | return result if result.is_a?(target_type.type) |
||
| 42 | end |
||
| 43 | message = "Can't denormalize #{target_type} out of #{value.class}" |
||
| 44 | mapping_error(message) |
||
| 45 | end |
||
| 46 | |||
| 64 |