Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove the duplication when creating Converters and Generators

Encapsulate it in a method and give the method the class to walk the
subclass tree for to create new objects.
  • Loading branch information...
commit 72853056369128c23ae7fd56673984e19e0afbe4 1 parent 5dea057
@mattr- mattr- authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/jekyll/site.rb
View
10 lib/jekyll/site.rb
@@ -88,12 +88,14 @@ def setup
end
end
+ self.converters = hydrate(Jekyll::Converter)
self.converters = Jekyll::Converter.subclasses.select do |c|
!self.safe || c.safe
end.map do |c|
c.new(self.config)
end
+ self.generators = hydrate(Jekyll::Generator)
self.generators = Jekyll::Generator.subclasses.select do |c|
!self.safe || c.safe
end.map do |c|
@@ -395,5 +397,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
Please sign in to comment.
Something went wrong with that request. Please try again.