class Decidim::ManifestRegistry

Takes care of holding and serving globally registered manifests.

Public Class Methods

new(entity) click to toggle source
# File lib/decidim/manifest_registry.rb, line 8
def initialize(entity)
  @entity = entity
end

Public Instance Methods

find(name) click to toggle source
# File 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
manifests() click to toggle source
# File lib/decidim/manifest_registry.rb, line 19
def manifests
  @manifests ||= Set.new
end
register(name) { |manifest| ... } click to toggle source
# File 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

Private Instance Methods

manifest_class() click to toggle source
# File lib/decidim/manifest_registry.rb, line 35
def manifest_class
  "Decidim::#{@entity.to_s.classify}Manifest".constantize
end