2024-10-02 15:58:19 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2025-09-22 14:01:58 -04:00
|
|
|
class Api::PointSerializer
|
|
|
|
|
EXCLUDED_ATTRIBUTES = %w[
|
|
|
|
|
created_at updated_at visit_id import_id user_id raw_data
|
|
|
|
|
country_id
|
|
|
|
|
].freeze
|
|
|
|
|
|
|
|
|
|
def initialize(point)
|
|
|
|
|
@point = point
|
|
|
|
|
end
|
2024-10-02 15:58:19 -04:00
|
|
|
|
|
|
|
|
def call
|
2025-09-22 14:01:58 -04:00
|
|
|
point.attributes.except(*EXCLUDED_ATTRIBUTES).tap do |attributes|
|
|
|
|
|
lat = point.lat
|
|
|
|
|
lon = point.lon
|
|
|
|
|
|
|
|
|
|
attributes['latitude'] = lat.nil? ? nil : lat.to_s
|
|
|
|
|
attributes['longitude'] = lon.nil? ? nil : lon.to_s
|
|
|
|
|
end
|
2024-10-02 15:58:19 -04:00
|
|
|
end
|
2025-09-22 14:01:58 -04:00
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
attr_reader :point
|
2024-10-02 15:58:19 -04:00
|
|
|
end
|