5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 01:06:22 +00:00
panel/app/models/metadata_float.rb

32 lines
471 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Un campo numérico de punto flotante
class MetadataFloat < MetadataTemplate
# Nada
def default_value
super || nil
end
def save
return true unless changed?
self[:value] = value.to_f
self[:value] = encrypt(value) if private?
true
end
# Indicarle al navegador que acepte números decimales
#
# @return [Float]
def step
0.05
end
private
def decrypt(value)
super(value).to_f
end
end