mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-24 12:26:21 +00:00
31 lines
517 B
Ruby
31 lines
517 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Un campo numérico
|
|
class MetadataNumber < MetadataTemplate
|
|
include Metadata::NonIndexableConcern
|
|
|
|
# El valor por defecto desde el esquema de datos o nada
|
|
#
|
|
# @return [Integer, nil]
|
|
def default_value
|
|
super || nil
|
|
end
|
|
|
|
# Convertir a Integer
|
|
#
|
|
# @return [Boolean]
|
|
def save
|
|
return true unless changed?
|
|
|
|
self[:value] = value.to_i
|
|
self[:value] = encrypt(value) if private?
|
|
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def decrypt(value)
|
|
super(value).to_i
|
|
end
|
|
end
|