Class: Mail2FrontMatter::PreProcessor

Inherits:
Object
  • Object
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



20
21
22
23
24
25
26
# File 'lib/mail2frontmatter/preprocessor.rb', line 20

def self.process(, body)
  @@processors.each do |processor|
    , body = processor.run(, body)
  end

  return , body
end

.register(options = {}) ⇒ Object

Raises:



12
13
14
15
16
17
18
# File 'lib/mail2frontmatter/preprocessor.rb', line 12

def self.register(options = {})
  raise InvalidProcessor, "run method not defined on #{self}" if !self.respond_to?(:run)
  raise ArgumentError, "options must be a hash" unless options.is_a? Hash
  @options = options

  @@processors << self
end