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
|
|
|
|
|
|
2025-09-29 16:27:07 -04:00
|
|
|
attributes['latitude'] = lat&.to_s
|
|
|
|
|
attributes['longitude'] = lon&.to_s
|
2025-12-06 14:54:49 -05:00
|
|
|
attributes['country_name'] = point.country_name
|
2025-09-22 14:01:58 -04:00
|
|
|
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
|