Skip to content

Commit df1fcd3

Browse files
committed
config shorthand
1 parent dfb0885 commit df1fcd3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/sprockets/railtie.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,50 +71,52 @@ def configure(&block)
7171
end
7272

7373
config.after_initialize do |app|
74-
manifest_path = File.join(app.root, 'public', app.config.assets.prefix)
74+
config = app.config
75+
76+
manifest_path = File.join(app.root, 'public', config.assets.prefix)
7577

7678
ActiveSupport.on_load(:action_view) do
7779
include Sprockets::Rails::Helper
7880

7981
# Copy relevant config to AV context
80-
self.debug_assets = app.config.assets.debug
81-
self.digest_assets = app.config.assets.digest
82-
self.assets_prefix = app.config.assets.prefix
82+
self.debug_assets = config.assets.debug
83+
self.digest_assets = config.assets.digest
84+
self.assets_prefix = config.assets.prefix
8385

8486
# Copy over to Sprockets as well
8587
context = app.assets.context_class
86-
context.assets_prefix = app.config.assets.prefix
87-
context.digest_assets = app.config.assets.digest
88-
context.config = app.config.action_controller
88+
context.assets_prefix = config.assets.prefix
89+
context.digest_assets = config.assets.digest
90+
context.config = config.action_controller
8991

90-
if app.config.assets.compile
92+
if config.assets.compile
9193
self.assets_environment = app.assets
9294
self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
9395
else
9496
self.assets_manifest = Sprockets::Manifest.new(manifest_path)
9597
end
9698
end
9799

98-
app.assets.js_compressor = app.config.assets.js_compressor
99-
app.assets.css_compressor = app.config.assets.css_compressor
100+
app.assets.js_compressor = config.assets.js_compressor
101+
app.assets.css_compressor = config.assets.css_compressor
100102

101103
# Run app.assets.configure blocks
102-
app.config.assets._blocks.each do |block|
104+
config.assets._blocks.each do |block|
103105
block.call app.assets
104106
end
105107

106108
# No more configuration changes at this point.
107109
# With cache classes on, Sprockets won't check the FS when files
108110
# change. Preferable in production when the FS only changes on
109111
# deploys when the app restarts.
110-
if app.config.cache_classes
112+
if config.cache_classes
111113
app.assets = app.assets.index
112114
end
113115

114-
if app.config.assets.compile
116+
if config.assets.compile
115117
if app.routes.respond_to?(:prepend)
116118
app.routes.prepend do
117-
mount app.assets => app.config.assets.prefix
119+
mount app.assets => config.assets.prefix
118120
end
119121
end
120122
end

0 commit comments

Comments
 (0)