Remove the duplication when creating Converters and Generators #841

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+10 −11
Split
View
@@ -88,17 +88,8 @@ def setup
end
end
- self.converters = Jekyll::Converter.subclasses.select do |c|
- !self.safe || c.safe
- end.map do |c|
- c.new(self.config)
- end
-
- self.generators = Jekyll::Generator.subclasses.select do |c|
- !self.safe || c.safe
- end.map do |c|
- c.new(self.config)
- end
+ self.converters = hydrate(Jekyll::Converter)
+ self.generators = hydrate(Jekyll::Generator)
end
# Internal: Setup the plugin search path
@@ -395,5 +386,13 @@ def getConverterImpl(klass)
raise "Converter implementation not found for #{klass}"
end
end
+
+ def hydrate(klass)
+ klass.subclasses.select do |c|
+ !self.safe || c.safe
+ end.map do |c|
+ c.new(self.config)
+ end
+ end
end
end