Sha256: c5b37418db03b656bd558b3a0f29b86d584e4998a3e51e59cdff4fe7bef137fd

Contents?: true

Size: 908 Bytes

Versions: 44

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    # This class infers the current component on an voting context
    # request parameters and injects it into the environment.
    class CurrentComponent
      # Public: Initializes the class.
      #
      # manifest - The manifest of the component to check against.
      def initialize(manifest)
        @manifest = manifest
      end

      # Public: Matches the request against a component and injects it into the
      #         environment.
      #
      # request - The request that holds the current component relevant information.
      #
      # Returns a true if the request matches an voting and a
      # component belonging to that voting, false otherwise
      def matches?(request)
        CurrentVoting.new.matches?(request) &&
          Decidim::CurrentComponent.new(@manifest).matches?(request)
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

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