22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/cyborg/plugin.rb', line 22
def create_engine(&block)
@engine = parent_module.const_set('Engine', Class.new(Rails::Engine) do
def cyborg_plugin_path
parent = Object.const_get(self.class.name.sub(/::Engine/,''))
Pathname.new parent.instance_variable_get("@gem_path")
end
def config
@config ||= Rails::Engine::Configuration.new(cyborg_plugin_path)
end
engine_name Cyborg.plugin.name
require 'cyborg/middleware'
initializer "#{name}.static_assets" do |app|
if !Cyborg.rails5? || app.config.public_file_server.enabled
app.middleware.insert_after ::ActionDispatch::Static, Cyborg::StaticAssets, "#{root}/public", engine_name: Cyborg.plugin.name
app.middleware.insert_before ::ActionDispatch::Static, Rack::Deflater
end
end
end)
@engine.instance_eval(&block) if block_given?
end
|