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.20.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.20.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.19.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.18.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.19.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.17.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.18.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.17.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.16.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.17.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.16.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.15.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.15.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.15.0 lib/decidim/verifications/registry.rb
decidim-verifications-0.14.4 lib/decidim/verifications/registry.rb
decidim-verifications-0.14.3 lib/decidim/verifications/registry.rb
decidim-verifications-0.14.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.14.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.13.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.12.2 lib/decidim/verifications/registry.rb