Sha256: f00a78fa3d3fc42e9973a1a64fc0fc15934481d9856d32ef867fbd67ca3f0694

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 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 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

5 entries across 5 versions & 1 rubygems

Version Path
decidim-verifications-0.8.4 lib/decidim/verifications/registry.rb
decidim-verifications-0.8.3 lib/decidim/verifications/registry.rb
decidim-verifications-0.8.2 lib/decidim/verifications/registry.rb
decidim-verifications-0.8.1 lib/decidim/verifications/registry.rb
decidim-verifications-0.8.0 lib/decidim/verifications/registry.rb