Class: RoomPlanPointsSerializer
- Inherits:
-
Object
- Object
- RoomPlanPointsSerializer
- Defined in:
- app/serializers/room_plan_points_serializer.rb
Overview
Only use this with a json or jsonb back end column
Class Method Summary collapse
Class Method Details
.cleanup_points_array(points = []) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/serializers/room_plan_points_serializer.rb', line 12 def self.cleanup_points_array(points = []) return [] if points.nil? # Use to_f instead of to_d to avoid BigDecimal serializing as strings in JSON # BigDecimal.to_json returns a string to preserve precision, but the JavaScript # room planner expects numeric values for polygon calculations points.map { |h| h.transform_values(&:to_f) } end |
.dump(points) ⇒ Object
4 5 6 |
# File 'app/serializers/room_plan_points_serializer.rb', line 4 def self.dump(points) cleanup_points_array(points) end |
.load(points) ⇒ Object
8 9 10 |
# File 'app/serializers/room_plan_points_serializer.rb', line 8 def self.load(points) cleanup_points_array(points) end |