Sha256: f015a92bafe0271616641b8667c3b011bef36fc18c8bfab1bb664d3917e4b0a0

Contents?: true

Size: 907 Bytes

Versions: 94

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

require "decidim/verifications/workflow_manifest"

module Decidim
  module Verifications
    #
    # Takes care of holding and accessing verification methods.
    #
    class Registry
      def register_workflow(name)
        manifest = WorkflowManifest.new(name: name.to_s)
        yield(manifest)
        add_workflow(manifest)
      end

      def unregister_workflow(manifest)
        workflow_collection.delete(manifest)
      end

      def add_workflow(manifest)
        manifest.validate!
        workflow_collection.add(manifest)
      end

      def clear_workflows
        workflow_collection.clear
      end

      def reset_workflows(*manifests)
        clear_workflows

        manifests.each do |manifest|
          add_workflow(manifest)
        end
      end

      def workflow_collection
        @workflow_collection ||= Set.new
      end
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
decidim-verifications-0.26.8 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.4 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.3 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.7 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.5 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.4 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.3 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.0.rc2 lib/decidim/verifications/registry.rb
decidim-verifications-0.27.0.rc1 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.0.rc2 lib/decidim/verifications/registry.rb
decidim-verifications-0.26.0.rc1 lib/decidim/verifications/registry.rb
decidim-verifications-0.25.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.25.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.25.0 lib/decidim/verifications/registry.rb