dawarich/app/serializers/api/point_serializer.rb
2025-11-21 00:10:08 +01:00

27 lines
540 B
Ruby

# frozen_string_literal: true
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
def call
point.attributes.except(*EXCLUDED_ATTRIBUTES).tap do |attributes|
lat = point.lat
lon = point.lon
attributes['latitude'] = lat&.to_s
attributes['longitude'] = lon&.to_s
attributes['country_name'] = point.country_name
end
end
private
attr_reader :point
end