Sha256: 137033d92cef5f8dd52658c96f97b94e4d4b74b3c25d12b36b9ffa03763edf7f
Contents?: true
Size: 796 Bytes
Versions: 39
Compression:
Stored size: 796 Bytes
Contents
# frozen_string_literal: true module Decidim module Votings class BallotResultForm < Decidim::Form attribute :valid_ballots_count, Integer attribute :blank_ballots_count, Integer attribute :null_ballots_count, Integer attribute :total_ballots_count, Integer validates :valid_ballots_count, :blank_ballots_count, :null_ballots_count, presence: true, numericality: true validate :ballot_total_count def ballot_total_count total_ballots_count == (valid_ballots_count.to_i + blank_ballots_count.to_i + null_ballots_count.to_i) end def map_model(model) self.total_ballots_count = model.results&.total_ballots&.first&.value || 0 end end end end
Version data entries
39 entries across 39 versions & 1 rubygems