lib/image_optim/railtie.rb in image_optim-0.21.0 vs lib/image_optim/railtie.rb in image_optim-0.22.0

- old
+ new

@@ -1,9 +1,19 @@ require 'image_optim' class ImageOptim # Adds image_optim as preprocessor for gif, jpeg, png and svg images class Railtie < Rails::Railtie + config.before_configuration do |app| + worker_names = ImageOptim::Worker.klasses.map(&:bin_sym) + app.config.assets.image_optim = + ActiveSupport::OrderedOptions.new do |hash, key| + if worker_names.include?(key.to_sym) + hash[key] = ActiveSupport::OrderedOptions.new + end + end + end + initializer 'image_optim.initializer' do |app| register_preprocessor(app) if register_preprocessor?(app) end def register_preprocessor?(app)