Class: Decidim::ManifestRegistry

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/lib/decidim/manifest_registry.rb

Overview

Takes care of holding and serving globally registered manifests.

Instance Method Summary collapse

Constructor Details

#initialize(entity) ⇒ ManifestRegistry

Returns a new instance of ManifestRegistry.



8
9
10
# File 'decidim-core/lib/decidim/manifest_registry.rb', line 8

def initialize(entity)
  @entity = entity
end

Instance Method Details

#find(name) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'decidim-core/lib/decidim/manifest_registry.rb', line 23

def find(name)
  name = name.to_s
  manifests.find do |manifest|
    manifest_name = manifest.name.to_s
    manifest_name == name ||
      manifest.try(:model_class_name) == name ||
      manifest_name.pluralize == name
  end
end

#manifestsObject



19
20
21
# File 'decidim-core/lib/decidim/manifest_registry.rb', line 19

def manifests
  @manifests ||= Set.new
end

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

Yields:

  • (manifest)


12
13
14
15
16
17
# File 'decidim-core/lib/decidim/manifest_registry.rb', line 12

def register(name)
  manifest = manifest_class.new(name: name.to_sym)
  yield(manifest)
  manifest.validate!
  manifests << manifest
end