Module: PufferPages::Handlers
- Defined in:
- lib/puffer_pages/handlers.rb,
lib/puffer_pages/handlers/base.rb,
lib/puffer_pages/handlers/yaml.rb
Defined Under Namespace
Classes: Base, HandlerMissing, Yaml
Class Method Summary
collapse
Class Method Details
.handlers ⇒ Object
5
6
7
|
# File 'lib/puffer_pages/handlers.rb', line 5
def self.handlers
@handlers ||= HashWithIndifferentAccess.new
end
|
.process(type, *args) ⇒ Object
13
14
15
16
|
# File 'lib/puffer_pages/handlers.rb', line 13
def self.process type, *args
raise HandlerMissing.new("Can not find handler for '#{type}' type") unless handlers[type]
handlers[type].process(*args)
end
|
.register(klass, *types) ⇒ Object
9
10
11
|
# File 'lib/puffer_pages/handlers.rb', line 9
def self.register klass, *types
handlers.merge! Hash[types.flatten.map { |type| [type, klass.new(type)] }]
end
|
.select ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/puffer_pages/handlers.rb', line 18
def self.select
handlers.values.map { |handler| [
I18n.t("puffer_pages.handlers.#{handler.type}"),
handler.type,
{ 'data-codemirror-mode' => handler.codemirror_mode }
] }
end
|