Class: Mail2FrontMatter::PreProcessor
- Inherits:
-
Object
- Object
- Mail2FrontMatter::PreProcessor
show all
- Defined in:
- lib/mail2frontmatter/preprocessor.rb
Defined Under Namespace
Classes: InvalidProcessor
Constant Summary
collapse
- @@processors =
Set.new
Class Method Summary
collapse
Class Method Details
.process(metadata, body) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/mail2frontmatter/preprocessor.rb', line 23
def self.process(metadata, body)
@@processors.each do |processor|
begin
metadata, body = processor.run(metadata, body)
rescue StandardError => e
Mail2FrontMatter.logger.error('processor failed!')
Mail2FrontMatter.logger.error(e)
end
end
[metadata, body]
end
|
.processors ⇒ Object
11
12
13
|
# File 'lib/mail2frontmatter/preprocessor.rb', line 11
def self.processors
@@processors
end
|
.register(options = {}) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/mail2frontmatter/preprocessor.rb', line 15
def self.register(options = {})
fail InvalidProcessor, "run method not defined on #{self}" unless self.respond_to?(:run)
fail ArgumentError, 'options must be a hash' unless options.is_a? Hash
@options = options
@@processors << self
end
|