Sha256: 3c269d9b537c75357001308af5dbfe7fb8e2a55d7068858d7f9db8c93bd8b4f6
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module ActiveFields module Field class DecimalArray < ActiveFields.config.field_base_class store_accessor :options, :min_size, :max_size, :min, :max # attribute :min_size, :integer # attribute :max_size, :integer # attribute :min, :decimal # attribute :max, :decimal validates :min_size, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true validates :max_size, comparison: { greater_than_or_equal_to: ->(r) { r.min_size || 0 } }, allow_nil: true validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min %i[min_size max_size].each do |column| define_method(column) do Casters::IntegerCaster.new.deserialize(super()) end define_method(:"#{column}=") do |other| super(Casters::IntegerCaster.new.serialize(other)) end end %i[min max].each do |column| define_method(column) do Casters::DecimalCaster.new.deserialize(super()) end define_method(:"#{column}=") do |other| super(Casters::DecimalCaster.new.serialize(other)) end end private def set_defaults; end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_fields-0.2.0 | app/models/active_fields/field/decimal_array.rb |