Skip to content

Commit

Permalink
prepare no cache file resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxa committed Apr 26, 2023
1 parent 45ee176 commit be78cc6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/chanko/config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
require "chanko/resolver/no_cache_file_system_resolver"

module Chanko
class NoCacheFileSystemResolver < ActionView::FileSystemResolver
def query(path, details, formats, locals, cache:)
super(path, details, formats, locals, cache: false)
end
end

module Config
class << self
attr_accessor(
Expand All @@ -21,7 +29,16 @@ def reset
self.propagated_errors = []
self.proxy_method_name = :unit
self.raise_error = Rails.env.development?
self.resolver = Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('7') ? ActionView::FileSystemResolver : ActionView::OptimizedFileSystemResolver

if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('7')
self.resolver = ActionView::FileSystemResolver
else
if Rails.env.development?
self.resolver = Chanko::Resolver::NoCacheFileSystemResolver
else
self.resolver = ActionView::OptimizedFileSystemResolver
end
end
self.units_directory_path = "app/units"
end

Expand Down
11 changes: 11 additions & 0 deletions lib/chanko/resolver/no_cache_file_system_resolver.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Chanko
module Resolver
if defined?(ActionView::OptimizedFileSystemResolver)
class NoCacheFileSystemResolver < ActionView::OptimizedFileSystemResolver
def query(path, details, formats, locals, cache:)
super(path, details, formats, locals, cache: false)
end
end
end
end
end

0 comments on commit be78cc6

Please sign in to comment.