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
11 12 13 14 15 16 17 |
# File 'app/serializers/room_plan_points_serializer.rb', line 11 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 { |v| v.to_f } } end |
.dump(points) ⇒ Object
3 4 5 |
# File 'app/serializers/room_plan_points_serializer.rb', line 3 def self.dump(points) cleanup_points_array(points) end |
.load(points) ⇒ Object
7 8 9 |
# File 'app/serializers/room_plan_points_serializer.rb', line 7 def self.load(points) cleanup_points_array(points) end |