mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-17 05:56:22 +00:00
35 lines
556 B
Ruby
35 lines
556 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Define un campo de coordenadas geográficas
|
|
class MetadataGeo < MetadataTemplate
|
|
def default_value
|
|
{ 'lat' => nil, 'lng' => nil }
|
|
end
|
|
|
|
def empty?
|
|
value == default_value
|
|
end
|
|
|
|
def save
|
|
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
|