Total Complexity | 1 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # frozen_string_literal: true |
||
13 | class Denormalizer < Interface |
||
14 | # :nocov: |
||
15 | # This methods accepts input data and type and creates corresponding |
||
16 | # entity. If necessary, type's factory may be called to instantiate |
||
17 | # entity. |
||
18 | # |
||
19 | # Method is provided with context and fallback block (with same |
||
20 | # signature) that allows to use default denormalization process. This |
||
21 | # allows denormalizer to use context to populate entity or use |
||
22 | # fallback block before or after processing: |
||
23 | # |
||
24 | # ```ruby |
||
25 | # data = { id: data } if data.is_a?(String) || data.is_a?(Symbol) |
||
26 | # yield(data, type, context) |
||
27 | # entity.id = entity.id || context.path.current.name |
||
28 | # entity |
||
29 | # ``` |
||
30 | # |
||
31 | # This method should not attempt to denormalize attributes, since that |
||
32 | # would be taken care of by mapper itself. |
||
33 | # |
||
34 | # @param [Object] data |
||
35 | # @param [AMA::Entity::Mapper::Type::Concrete] type |
||
36 | # @param [AMA::Entity::Mapper::Context] context |
||
37 | # @param [Proc] block |
||
38 | # @return [Object] |
||
39 | def denormalize(data, type, context = nil, &block) |
||
40 | abstract_method |
||
41 | end |
||
42 | # :nocov: |
||
43 | end |
||
44 | end |
||
48 |