2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
class Archetype
|
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
|
|
|
attr_accessor :id, :options
|
|
|
|
|
|
|
|
def initialize(id, options)
|
|
|
|
@id = id
|
2013-02-25 10:42:20 -06:00
|
|
|
@options = options
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def attributes
|
2023-01-09 06:10:19 -06:00
|
|
|
{ id: @id, options: @options }
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.default
|
2023-01-09 06:10:19 -06:00
|
|
|
"regular"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.private_message
|
2023-01-09 06:10:19 -06:00
|
|
|
"private_message"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
2014-06-16 09:17:27 -05:00
|
|
|
def self.banner
|
2023-01-09 06:10:19 -06:00
|
|
|
"banner"
|
2014-06-16 09:17:27 -05:00
|
|
|
end
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
def self.list
|
2024-05-27 05:27:13 -05:00
|
|
|
return [] if @archetypes.blank?
|
2013-02-05 13:16:51 -06:00
|
|
|
@archetypes.values
|
|
|
|
end
|
|
|
|
|
2017-07-27 20:20:09 -05:00
|
|
|
def self.register(name, options = {})
|
2013-02-05 13:16:51 -06:00
|
|
|
@archetypes ||= {}
|
|
|
|
@archetypes[name] = Archetype.new(name, options)
|
|
|
|
end
|
|
|
|
|
2024-05-24 09:15:53 -05:00
|
|
|
def self.deregister(name)
|
|
|
|
@archetypes ||= {}
|
|
|
|
@archetypes.delete(name)
|
|
|
|
end
|
|
|
|
|
2014-06-16 09:17:27 -05:00
|
|
|
# default archetypes
|
2023-01-09 06:10:19 -06:00
|
|
|
register "regular"
|
|
|
|
register "private_message"
|
|
|
|
register "banner"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|