Module: GoldenFleece::Model::Normalization
- Includes:
- Utility
- Defined in:
- lib/golden_fleece/model/normalization.rb
Constant Summary
Constants included from Utility
Instance Method Summary collapse
Methods included from Utility
#build_json_path, #cast_boolean, #deep_stringify_keys, #error_suffix
Instance Method Details
#normalize_fleece ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/golden_fleece/model/normalization.rb', line 6 def normalize_fleece self.class.fleece_context.schemas.each do |attribute, schema| persisted_json = read_attribute attribute computed_json = deep_stringify_keys schema.reduce({}) { |memo, (schema_name, schema)| memo[schema_name] = schema.value.compute(self) memo } if !persisted_json.nil? && persisted_json != computed_json write_attribute attribute, computed_json end end end |