discourse/lib/archetype.rb

44 lines
688 B
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
class Archetype
include ActiveModel::Serialization
attr_accessor :id, :options
def initialize(id, options)
@id = id
2013-02-26 00:42:20 +08:00
@options = options
2013-02-06 03:16:51 +08:00
end
def attributes
2013-02-26 00:42:20 +08:00
{'id' => @id,
2013-02-06 03:16:51 +08:00
'options' => @options}
end
def self.default
2013-02-26 00:42:20 +08:00
'regular'
2013-02-06 03:16:51 +08:00
end
def self.poll
'poll'
end
def self.private_message
'private_message'
end
def self.list
return [] unless @archetypes.present?
@archetypes.values
end
def self.register(name, options={})
@archetypes ||= {}
@archetypes[name] = Archetype.new(name, options)
end
# By default we have a regular archetype and a private message
register 'regular'
register 'private_message'
end