Sha256: ea8819de13f1a2abcfaddf7fab79175ff538dc1ca4e71b3d375d0090e3eafc7b
Contents?: true
Size: 743 Bytes
Versions: 5
Compression:
Stored size: 743 Bytes
Contents
require "govuk_document_types/version" require "yaml" module GovukDocumentTypes DATA = YAML.load_file(File.dirname(__FILE__) + "/../data/supertypes.yml") SUPERGROUPS = YAML.load_file(File.dirname(__FILE__) + "/../data/supergroups.yml") def self.supertypes(document_type:) types = {} DATA.each do |name, definition| group_data = definition["items"].find do |supertype| supertype['document_types'].include?(document_type) end type = (group_data && group_data["id"]) || definition["default"] types.merge!(name => type) end types end def self.supergroups(ids:) groups = SUPERGROUPS["content_purpose_supergroup"]["items"] groups.select { |g| ids.include?(g["id"]) } end end
Version data entries
5 entries across 5 versions & 1 rubygems