Module: Bronze::Entities::Normalization
- Extended by:
- SleepingKingStudios::Tools::Toolbox::Mixin
- Included in:
- Bronze::Entity
- Defined in:
- lib/bronze/entities/normalization.rb
Overview
Module for transforming entities to and from a normal form.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#normalize(permit: []) ⇒ Hash
Returns a normalized representation of the entity.
Instance Method Details
#normalize(permit: []) ⇒ Hash
Returns a normalized representation of the entity. The normal representation of an entity is a hash with String keys. Each value must be nil, a literal value (true, false, a String, an Integer, a Float, etc), an Array of normal values, or a Hash with String keys and normal values.
49 50 51 52 53 54 55 56 |
# File 'lib/bronze/entities/normalization.rb', line 49 def normalize(permit: []) self.class.each_attribute.with_object({}) do |(name, ), hsh| value = get_attribute(name) value = normalize_attribute(value, metadata: , permit: permit) hsh[name.to_s] = value end end |