discourse/lib/archetype.rb
Ted Johansson 69205cb1e5
DEV: Catch missing translations during test runs (#26258)
This configuration makes it so that a missing translation will raise an error during test execution. Better discover there than after deploy.
2024-05-24 22:15:53 +08:00

49 lines
777 B
Ruby

# frozen_string_literal: true
class Archetype
include ActiveModel::Serialization
attr_accessor :id, :options
def initialize(id, options)
@id = id
@options = options
end
def attributes
{ id: @id, options: @options }
end
def self.default
"regular"
end
def self.private_message
"private_message"
end
def self.banner
"banner"
end
def self.list
return [] unless @archetypes.present?
@archetypes.values
end
def self.register(name, options = {})
@archetypes ||= {}
@archetypes[name] = Archetype.new(name, options)
end
def self.deregister(name)
@archetypes ||= {}
@archetypes.delete(name)
end
# default archetypes
register "regular"
register "private_message"
register "banner"
end