Class: AMA::Entity::Mapper::Engine::RecursiveNormalizer
- Inherits:
-
Object
- Object
- AMA::Entity::Mapper::Engine::RecursiveNormalizer
- Defined in:
- lib/ama-entity-mapper/engine/recursive_normalizer.rb
Overview
Helper and self-explanatory engine class
Instance Method Summary collapse
-
#initialize(registry) ⇒ RecursiveNormalizer
constructor
A new instance of RecursiveNormalizer.
- #normalize(entity, ctx, type = nil) ⇒ Object
Constructor Details
#initialize(registry) ⇒ RecursiveNormalizer
Returns a new instance of RecursiveNormalizer.
13 14 15 |
# File 'lib/ama-entity-mapper/engine/recursive_normalizer.rb', line 13 def initialize(registry) @registry = registry end |
Instance Method Details
#normalize(entity, ctx, type = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ama-entity-mapper/engine/recursive_normalizer.rb', line 20 def normalize(entity, ctx, type = nil) type ||= find_type(entity.class) target = entity ctx.logger.debug("Normalizing #{entity.class} as #{type.type}") if type.virtual = "Type #{type.type} is virtual, skipping to attributes" ctx.logger.debug() else target = type.normalizer.normalize(entity, type, ctx) end target_type = find_type(target.class) process_attributes(target, target_type, ctx) end |