Module: Bronze::Entities::Normalization::ClassMethods
- Defined in:
- lib/bronze/entities/normalization.rb
Overview
Class methods to define when including Normalization in a class.
Instance Method Summary collapse
-
#denormalize(attributes) ⇒ Bronze::Entity
Returns an entity instance from the given normalized representation.
Instance Method Details
#denormalize(attributes) ⇒ Bronze::Entity
Returns an entity instance from the given normalized representation.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bronze/entities/normalization.rb', line 19 def denormalize(attributes) entity = new entity.send(:validate_attributes, attributes) each_attribute do |name, | value = attributes[name] || attributes[name.to_s] value = .transform.denormalize(value) if .transform? next if value.nil? && .primary_key? entity.set_attribute(name, value) end entity end |