Sha256: 8d12a4f7f3731731289bce79d550fef5a7568f193b0378cfd81a4d552a23ad8f

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

module Pageflow
  # List of file importers will be maintained using this class
  # File importer plugin is required to register itself to this list
  class FileImporters
    include Enumerable

    def initialize
      clear
    end

    def register(name, file_importer)
      @file_importers[name] = file_importer
    end

    def clear
      @file_importers = {}
    end

    def each(&block)
      @file_importers.values.each(&block)
    end

    def find_by_name!(name)
      fetch_by_name(name) do
        raise "Unknown file importer with name '#{name}'."
      end
    end

    def fetch_by_name(name, &block)
      @file_importers.fetch(name, &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pageflow-15.1.0.beta2 lib/pageflow/file_importers.rb
pageflow-15.1.0.beta1 lib/pageflow/file_importers.rb