Class: Decidim::Verifications::Registry

Inherits:
Object
  • Object
show all
Defined in:
decidim-verifications/lib/decidim/verifications/registry.rb

Overview

Takes care of holding and accessing verification methods.

Instance Method Summary collapse

Instance Method Details

#add_workflow(manifest) ⇒ Object



21
22
23
24
# File 'decidim-verifications/lib/decidim/verifications/registry.rb', line 21

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

#clear_workflowsObject



26
27
28
# File 'decidim-verifications/lib/decidim/verifications/registry.rb', line 26

def clear_workflows
  workflow_collection.clear
end

#register_workflow(name) {|manifest| ... } ⇒ Object

Yields:

  • (manifest)


11
12
13
14
15
# File 'decidim-verifications/lib/decidim/verifications/registry.rb', line 11

def register_workflow(name)
  manifest = WorkflowManifest.new(name: name.to_s)
  yield(manifest)
  add_workflow(manifest)
end

#reset_workflows(*manifests) ⇒ Object



30
31
32
33
34
35
36
# File 'decidim-verifications/lib/decidim/verifications/registry.rb', line 30

def reset_workflows(*manifests)
  clear_workflows

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

#unregister_workflow(manifest) ⇒ Object



17
18
19
# File 'decidim-verifications/lib/decidim/verifications/registry.rb', line 17

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

#workflow_collectionObject



38
39
40
# File 'decidim-verifications/lib/decidim/verifications/registry.rb', line 38

def workflow_collection
  @workflow_collection ||= Set.new
end