Sha256: 4216de05bf1daf78947f6ebcac2f3a35bbf7594595e8da023972ae35645ebafd

Contents?: true

Size: 1.52 KB

Versions: 35

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module Decidim
  module Verifications
    autoload :Adapter, "decidim/verifications/adapter"
    autoload :Registry, "decidim/verifications/registry"

    #
    # Provides direct access to the verification registry
    #
    class << self
      delegate :clear_workflows, to: :registry

      #
      # Restores registered verification workflows to the array being passed in
      #
      # Useful for testing.
      #
      def reset_workflows(*manifests)
        registry.reset_workflows(*manifests)
      end

      #
      # Registers a new verification workflow using the workflow manifest API
      #
      def register_workflow(name, &block)
        registry.register_workflow(name, &block)
      end

      #
      # Registers a verification workflow using the workflow manifest API
      #
      def unregister_workflow(name)
        manifest = find_workflow_manifest(name)

        registry.unregister_workflow(manifest)
      end

      #
      # Finds a verification workflow by name
      #
      def find_workflow_manifest(name)
        workflows.find { |workflow| workflow.name == name.to_s }
      end

      #
      # Collection of registered verification workflows
      #
      def workflows
        registry.workflow_collection
      end

      #
      # Collection of registered verification workflows having an admin engine
      #
      def admin_workflows
        workflows.select(&:admin_engine)
      end

      private

      def registry
        @registry ||= Registry.new
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
decidim-verifications-0.21.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.20.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.20.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.19.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.18.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.19.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.17.2 lib/decidim/verifications/workflows.rb
decidim-verifications-0.18.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.17.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.16.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.17.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.16.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.15.2 lib/decidim/verifications/workflows.rb
decidim-verifications-0.15.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.15.0 lib/decidim/verifications/workflows.rb
decidim-verifications-0.14.4 lib/decidim/verifications/workflows.rb
decidim-verifications-0.14.3 lib/decidim/verifications/workflows.rb
decidim-verifications-0.14.2 lib/decidim/verifications/workflows.rb
decidim-verifications-0.14.1 lib/decidim/verifications/workflows.rb
decidim-verifications-0.13.1 lib/decidim/verifications/workflows.rb