Sha256: ad0b172013139d8da7e445c4d2ef442b682fa822bfee7ebc83b6d279f30dc065

Contents?: true

Size: 642 Bytes

Versions: 2

Compression:

Stored size: 642 Bytes

Contents

# Pre-processes blog data, allows hooks

module Mail2FrontMatter
  class PreProcessor
    require 'set'

    class InvalidProcessor < StandardError ; end

    @@processors = Set.new

    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

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

      return metadata, body
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mail2frontmatter-0.0.6 lib/mail2frontmatter/preprocessor.rb
mail2frontmatter-0.0.5 lib/mail2frontmatter/preprocessor.rb