Sha256: d895d0d322bac3ee774ecaf4bdc402fed6cb3ce469e0a8318186c7a9379403ee

Contents?: true

Size: 622 Bytes

Versions: 44

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Votings
    # Common logic to ordering resources
    module Orderable
      extend ActiveSupport::Concern

      included do
        include Decidim::Orderable

        private

        # Available orders based on enabled settings
        def available_orders
          %w(random recent)
        end

        def reorder(votings)
          case order
          when "recent"
            votings.order_by_most_recent
          else
            votings.order_randomly(random_seed)
          end
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.9 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.28.3 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.8 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.28.2 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.7 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.28.1 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.6 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.26.10 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.26.9 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.28.0 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.5 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.28.0.rc5 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.28.0.rc4 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.26.8 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.4 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.3 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.26.7 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.26.5 app/controllers/concerns/decidim/votings/orderable.rb
decidim-elections-0.27.2 app/controllers/concerns/decidim/votings/orderable.rb