5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 12:26:21 +00:00
panel/app/models/metadata_geo.rb
f 915ba0761f
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat: usar mixins
2023-10-06 10:53:19 -03:00

38 lines
635 B
Ruby

# frozen_string_literal: true
# Define un campo de coordenadas geográficas
class MetadataGeo < MetadataTemplate
include Metadata::IndexableConcern
def default_value
super || { 'lat' => nil, 'lng' => nil }
end
def empty?
value == default_value
end
def save
return true unless changed?
return true if empty?
self[:value] = value.transform_values(&:to_f)
self[:value] = encrypt(value) if private?
true
end
private
def encrypt(value)
value.transform_values do |v|
super v
end
end
def decrypt(value)
value.transform_values do |v|
super v
end
end
end