Sha256: 5fb4aaa40c522b4174b2cd7a825643c53d43203522ad962b19739cabd88eff2e
Contents?: true
Size: 810 Bytes
Versions: 89
Compression:
Stored size: 810 Bytes
Contents
# frozen_string_literal: true module Decidim module Sortitions module Admin # This class represents a draw for selecting proposals. class Draw attr_reader :sortition # Sugar syntax. Retrieves the list of selected proposals. def self.for(sortition) new(sortition).results end # Initializes the draw class. Receives a sortition. def initialize(sortition) @sortition = sortition end # Executes the draw and return the selected proposal ids. def results proposals.sample(sortition.target_items, random: Random.new(sortition.seed)).pluck(:id) end def proposals @proposals ||= ParticipatorySpaceProposals.for(sortition).to_a end end end end end
Version data entries
89 entries across 89 versions & 1 rubygems