Skip to content

Commit b8db8b8

Browse files
Move fetcher into it’s own method
1 parent 1780066 commit b8db8b8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/critical-path-css-rails.rb

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@ module CriticalPathCss
66
CACHE_NAMESPACE = 'critical-path-css'.freeze
77

88
def self.generate(route)
9-
::Rails.cache.write(
10-
route,
11-
CssFetcher.new(config).fetch_route(route),
12-
namespace: CACHE_NAMESPACE,
13-
expires_in: nil
14-
)
9+
::Rails.cache.write(route, fetcher.fetch_route(route), namespace: CACHE_NAMESPACE, expires_in: nil)
1510
end
1611

1712
def self.generate_all
18-
CssFetcher.new(config).fetch.each do |route, css|
13+
fetcher.fetch.each do |route, css|
1914
::Rails.cache.write(route, css, namespace: CACHE_NAMESPACE, expires_in: nil)
2015
end
2116
end
@@ -32,7 +27,7 @@ def self.fetch(route)
3227
::Rails.cache.read(route, namespace: CACHE_NAMESPACE) || ''
3328
end
3429

35-
def self.config
36-
@config ||= Configuration.new(CriticalPathCss::Rails::ConfigLoader.new.load)
30+
def self.fetcher
31+
@fetcher ||= CssFetcher.new(Configuration.new(CriticalPathCss::Rails::ConfigLoader.new.load))
3732
end
3833
end

0 commit comments

Comments
 (0)