Sha256: 5d1fd8cc6d9593b559757c4766b960b8a27366d2941b26248c58a1ed3d291385
Contents?: true
Size: 960 Bytes
Versions: 37
Compression:
Stored size: 960 Bytes
Contents
# frozen_string_literal: true module Decidim # # Takes care of holding and serving globally registered manifests. # class ManifestRegistry def initialize(entity) @entity = entity end def register(name) manifest = manifest_class.new(name: name.to_sym) yield(manifest) manifest.validate! manifests << manifest end def manifests @manifests ||= Set.new end def find(name) manifests.find { |manifest| manifest.name == name } end def resource_manifests @resource_manifests ||= manifests.flat_map(&:resource_manifests) end def find_resource_manifest(resource_name_or_klass) resource_manifests.find do |manifest| manifest.model_class == resource_name_or_klass || manifest.name.to_s == resource_name_or_klass.to_s end end private def manifest_class "Decidim::#{@entity.to_s.classify}Manifest".constantize end end end
Version data entries
37 entries across 37 versions & 2 rubygems