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.24.1 app/constraints/decidim/votings/current_component.rb
decidim-elections-0.24.0 app/constraints/decidim/votings/current_component.rb
decidim-elections-0.24.0.rc2 app/constraints/decidim/votings/current_component.rb
decidim-elections-0.24.0.rc1 app/constraints/decidim/votings/current_component.rb