Class: HeatLossSerializer
- Inherits:
-
Object
- Object
- HeatLossSerializer
- Defined in:
- app/serializers/heat_loss_serializer.rb
Overview
Only use this with a json or jsonb back end column
Class Method Summary collapse
Class Method Details
.cleanup_hash(hash) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/serializers/heat_loss_serializer.rb', line 11 def self.cleanup_hash(hash) return {} unless hash.present? if hash['avg_temperature_ranges'].present? hash['avg_temperature_ranges'] = hash['avg_temperature_ranges'].map{|v| v['range'] = v['range'].map(&:to_d); v } end if hash['hlc_by_object'].present? hash['hlc_by_object'] = hash['hlc_by_object'].map{|v| v['heat_loss'] = v['heat_loss'].to_d; v } end hash end |
.dump(hash) ⇒ Object
3 4 5 |
# File 'app/serializers/heat_loss_serializer.rb', line 3 def self.dump(hash) cleanup_hash(hash) end |
.load(hash) ⇒ Object
7 8 9 |
# File 'app/serializers/heat_loss_serializer.rb', line 7 def self.load(hash) cleanup_hash(hash) end |