Class: Decidim::Verifications::Registry

Inherits:
Object
  • Object
show all
Defined in:
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



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

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

#clear_workflowsObject



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

def clear_workflows
  workflow_collection.clear
end

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

Yields:

  • (manifest)


11
12
13
14
15
# File '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



26
27
28
29
30
31
32
# File 'lib/decidim/verifications/registry.rb', line 26

def reset_workflows(*manifests)
  clear_workflows

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

#workflow_collectionObject



34
35
36
# File 'lib/decidim/verifications/registry.rb', line 34

def workflow_collection
  @workflow_collection ||= Set.new
end